Is there a MessageBox equivalent in WPF? Is there a MessageBox equivalent in WPF? wpf wpf

Is there a MessageBox equivalent in WPF?


The WPF equivalent would be the System.Windows.MessageBox. It has a quite similar interface, but uses other enumerations for parameters and return value.


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.


WPF contains the following MessageBox:

if (MessageBox.Show("Do you want to Save?", "Confirm",     MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes){}