Is there a MessageBox equivalent in WPF?

前端 未结 9 869
耶瑟儿~
耶瑟儿~ 2020-11-29 17:49

Is there a standard message box in WPF, like WinForms\' System.Windows.Forms.MessageBox.Show(), or should I use the WinForms message box?

相关标签:
9条回答
  • 2020-11-29 18:20

    In WPF it seems this code,

    System.Windows.Forms.MessageBox.Show("Test");
    

    is replaced with:

    System.Windows.MessageBox.Show("Test");
    
    0 讨论(0)
  • 2020-11-29 18:25

    You can use this:

    MessageBoxResult result = MessageBox.Show("Do you want to close this window?",
                                              "Confirmation",
                                              MessageBoxButton.YesNo,
                                              MessageBoxImage.Question);
    if (result == MessageBoxResult.Yes)
    {
        Application.Current.Shutdown();
    }
    

    For more information, visit MessageBox in WPF.

    0 讨论(0)
  • 2020-11-29 18:25

    The equivalent to WinForms' MessageBox in WPF is called System.Windows.MessageBox.

    0 讨论(0)
提交回复
热议问题