Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I popup in message in UWP?

Tags:

popup

uwp

In my Windows 8.1 app I used MessageBox.Show() to popup a message. That is gone in UWP. How can I show a message?

like image 501
Boris Pluimvee Avatar asked Jun 29 '16 15:06

Boris Pluimvee


People also ask

How do I show pop up in UWP?

To show a Popup, set its IsOpen property to true. To hide the Popup, set IsOpen to false. You can set IsLightDismissEnabled to make the Popup hide automatically when a user taps anywhere away from it.

What is C# UWP?

Windows 10 introduced the Universal Windows Platform (UWP), which provides a common app platform on every device that runs Windows. The UWP core APIs are the same on all Windows devices.

What is UWP in .NET core?

NET Core. UWP is also known as Windows 10 UWP application. This application does not run on previous versions of Windows but will only run on future version of Windows. Following are a few exceptions where UWP will run smoothly.


1 Answers

Yup, indeed something like that, the new method is to use the MessageDialog class. You have to create an object of that type. You can also add buttons. It's a bit more complex I think. But you can also use some shortcuts here. To just show a message, use this:

await new MessageDialog("Your message here", "Title of the message dialog").ShowAsync();
To show an simple Yes/No message, you can do it like this:

MessageDialog dialog = new MessageDialog("Yes or no?");
dialog.Commands.Add(new UICommand("Yes", null));
dialog.Commands.Add(new UICommand("No", null));
dialog.DefaultCommandIndex = 0;
dialog.CancelCommandIndex = 1;
var cmd = await dialog.ShowAsync();

if (cmd.Label == "Yes")
{
    // do something
}
like image 64
Jessevl Avatar answered Sep 30 '22 21:09

Jessevl