· Windows RT CSharp

Queue for MessageDialog in Windows RT

When I write Windows Store applications, I use MessageDialog a lot. It’s the easiest way to show a quick informative pop-up message or a question to the user. However, when you tend to use this quite often, you’ll probably run into a problem.

The Windows Runtime framework doesn’t allow you to stack MessageDialogs, queue them etc. So if you need to display one, you’ll have to make sure that no other MessageDialog is already open. Checking if there is an open MessageDialog is not that easy unless you keep references to all the MessageDialogs you create. There are a few cases in which this would be annoying.

The singleton class below will make sure that you can queue MessageDialogs and that this problem will never occur.

Instead of using

myDialog.ShowAsync();

use

MessageDialogQueue.PushMessageDialog(myDialog);

The dialog will be displayed after all previous MessageDialogs are closed. Do this for all your MessageDialogs or you’ll still run into the problem I mentioned.

  • LinkedIn
  • Tumblr
  • Reddit
  • Google+
  • Pocket

In case you have any further questions, remarks or suggestions about this post, feel free to drop me a tweet or an email! You can also find me on Slack on the Xamarin Chat. I go by the username sam_d.

About the author

Sam is a C# developer who builds mobile (cross platform) apps with Xamarin. He's been a certified Xamarin mobile developer since 2016. Sam likes to experiment with all kinds of programming languages and software frameworks. More info