Is there a MessageBox equivalent in WPF?

前端 未结 9 969
耶瑟儿~
耶瑟儿~ 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: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.

提交回复
热议问题