How to get MessageBox.Show() to pop up in the middle of my WPF application?

前端 未结 6 1458
忘掉有多难
忘掉有多难 2020-12-17 08:39

I have a 700w x 300h WPF applciation and can drag it anywhere on my large screen.

When my application executes:

MessageBox.Show(\"Sorry, this functio         


        
6条回答
  •  清酒与你
    2020-12-17 09:13

    If your app has several windows, you might want to use Application.Current.MainWindow:

    MessageBox.Show(Application.Current.MainWindow, "Can't login with given names.", "Login Failure", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.Cancel);
    

提交回复
热议问题