How to create a popup in UWP

Viewed 6553

I'm trying to make a desktop application with Width= 600 Height=500. How to create a popup dialog that overlaps complete window of the app? When the user clicks on Terms&Condition (within mainpage) I want to popup a dialog like this?

3 Answers

You can create a ContentDialog or MessageDialog

ContentDialog Example

ContentDialog noWifiDialog = new ContentDialog()
{
    Title = "No wifi connection",
    Content = "Check connection and try again.",
    CloseButtonText = "Ok"
};

await noWifiDialog.ShowAsync();

Add the following to your XAML code.

<Popup x:Name="Nav_Pop" 
        IsOpen="False" 
        Width="750" 
        Height="700" 
        IsLightDismissEnabled="True"
        VerticalOffset="10"
        HorizontalOffset="200"
        VerticalAlignment="Center" HorizontalAlignment="Center"
        LightDismissOverlayMode="On">
</Popup>

Note: Set the IsLightDismissEnabled Property to True to dismiss the popup by clicking anywhere on the app.

Inside the popup tags, you can add required child elements.

Till the end I make a New ContentDialog (Add>NewItem>ContentDialog1). After in ContentDialog1.xaml I paste defaul style of ContentDialog inside of and in MainPage.xaml.cs I instatiate this dialog and show him after with this code: " ContentDialog1 dialog = new ContentDialog1();
await dialog.ShowAsync();".

But now problem is that this dialog is inside of my frame. How can I overlay this dialog on application ?

Related