I am trying to implement Mahapps Metro Message box in my code, but want to use it on a class, not any WPF Window , can I achieve this ?, because I don't want to use ordinary Message Boxes.
switch(x)
{
case "a":
//Do something
break;
case "b":
var result = MessageBox.Show("TitleMessage","If you want to continue",MessageboxButton.YesNo);
break;
}
so instead of this MessageBox, I want to use Mahapps Message Box , then use this result variable.
Since the ShowMessageAsync method is an extension method of the MetroWindow class, you need to have a window to be able to call it.
If your applications's main window is a metro window you should be able to call the method like this from any class that has a reference to the PresentationFramework assembly:
var metroWindow = (Application.Current.MainWindow as MetroWindow);
await metroWindow.ShowMessageAsync("title", "message...");
Please refer to the following links for more information: https://github.com/MahApps/MahApps.Metro/issues/1129
Can't use await on ShowMessageAsync
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With