I’m attempting to create a modal confirmation dialog that always appears in the centre of the screen.
I’ve tried to use:
ConfirmCreate confirmCreate = new ConfirmCreate(); // ConfirmCreate extends Window.
bool? dialogResult = confirmCreate.ShowDialog();
confirmCreate.Owner = this;
confirmCreate.WindowStartupLocation = WindowStartupLocation.CenterOwner;
… and…
ConfirmCreate confirmCreate = new ConfirmCreate();
bool? dialogResult = confirmCreate.ShowDialog();
confirmCreate.WindowStartupLocation = WindowStartupLocation.CenterScreen;
… and even …
ConfirmCreate confirmCreate = new ConfirmCreate(); // ConfirmCreate is a subclass of Window.
bool? dialogResult = confirmCreate.ShowDialog();
confirmCreate.WindowStartupLocation = WindowStartupLocation.Manual;
confirmCreate.Left = Width/2 - confirmCreate.Width/2;
confirmCreate.Top = Height/2 - confirmCreate.Height/2;
To no avail, can someone explain why this isn’t working?
Try all your options with
confirmCreate.ShowDialog();at the end. In other words, set the settings forWindowStartupLocationand then callShowDialog()