Search code examples
c#windows-phone-7messagebox

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.


Solution

  • 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