WPF WindowStartupLocation=”CenterOwner” not really center, and pops all over, why?

Probably because you didn’t set the owner:

this.Owner = App.MainWindow; // for example

That’s how I do it and it centers the window perfectly all the time.

To extend on what Will Eddins commented, you could create an overload method for ShowDialog() or Show() in your Window:

public void ShowDialog(Window owner)
{
    this.Owner = owner;
    this.ShowDialog();
}

public void Show(Window owner)
{
    this.Owner = owner;
    this.Show();
}

Or overload a constructor:

public MyWindow(Window owner)
    : this()
{
    this.Owner = owner;
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)