Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How I can run MessageBox.Show() from App.xaml.cs

Can I run MessageBox.Show() from App.xaml.cs, so it is shown on current page. Please provide some code to this solution, or some other solution. I need to show some system message which is relevant for whole application.

like image 595
infoexpert.it Avatar asked Dec 13 '22 09:12

infoexpert.it


1 Answers

Not sure, but would this not work?

Deployment.Current.Dispatcher.BeginInvoke(() =>
{
 MessageBox.Show("");
}
);

You could also use the navigation data that is available in App.xaml.cs to determine the current Page and execute on that page.

I guess whatever you come up with, the app needs to be in a stable state, you probably can't do this when your handling (unhandled) exception. You should tell us a bit more so we understand why you want to do this. It seems that seomthing is wrong with your setup if you have to call MessageBox.Show from App.xaml.cs

like image 59
invalidusername Avatar answered Dec 14 '22 23:12

invalidusername