0
votes

How can i make the window and the messagebox be opened at the top of the screen but not to keep this state? Topmost property doesn't work here, because it makes the window to be always at the top, and i need it only to be opened at the top. The problem is that when the topmost = false, our windows and messageboxes are opened not at the top of the screen sometimes, which can make users uncomfortable. Any ideas?

3
Just to confirm: MessageBox as created by the System.Windows.MessageBox class, or your own message/dialog box, created in WPF?Kieren Johnstone
Ah, forgot to mention it. We're using a default System.Windows.MessageBoxProton

3 Answers

3
votes

Are you looking for Window.Activate? This is the preferred mechanism for bringing your window to the attention of the user.

Be aware that it comes with restrictions.

0
votes

while createing windows try with

window.Owner = owner or Window.GetWindow(this)

and see whether windows coming on top

0
votes

Simplest catch: using MessageBoxOptions.DefaultDesktopOnly keeps the MessageBox on top of the window.

MessageBox.Show("You entered an incorrect value.Try once more.", "Wrong input", MessageBoxButton.OK, MessageBoxImage.Exclamation,MessageBoxResult.OK,MessageBoxOptions.DefaultDesktopOnly);