Andrian Pirlici
Andrian Pirlici

Reputation: 95

How to create a popup in UWP

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?

Upvotes: 4

Views: 9150

Answers (3)

user2958553
user2958553

Reputation: 11

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.

Upvotes: 1

Andrian Pirlici
Andrian Pirlici

Reputation: 95

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 ?

Upvotes: 0

Muhammad Touseef
Muhammad Touseef

Reputation: 4465

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();

Upvotes: 4

Related Questions