4

I am trying to display a page as a dialog in Universal Window App (Windows 10).

In WFP, there is this ShowDialog to call on Window:

var msgBox = new MessageWindow();
msgBox.Owner = App.Current.MainWindow;
msgBox.WindowStartupLocation = WindowStartupLocation.CenterOwner;
msgBox.SetMessage(message, messageCategory);
msgBox.ShowDialog();

How do I do something like that in Universal Window App (Windows 10)?

Here is a Sample Picture of how it looks

user3863376
  • 63
  • 1
  • 2
  • 4

2 Answers2

10

There is no exact same MessageWindow in UWP. It depends on what you want to do with the dialog.

In UWP, there are many options we can choose to display a popup/dialog to show information or require user interaction.

Dialog:

Lightweight Control:

If above cannot meet your requirement, try Popup which gives you more flexibility.

Alan Yao - MSFT
  • 3,284
  • 1
  • 17
  • 16
  • Thank you so much for the quick response. I decided to go with the ContentDialog route. We are trying to port to UWP and the ContenDialog would keep the same structure. – user3863376 Nov 03 '15 at 07:02
  • Thank you @Alan. I used PopUp to show an image tag. I added image in a usercontrol. this usercontrol was child of popup. and i just controlled isOpen of popup and enabled the IsLightDismissEnabled property. It's beautiful. Now I have to find a way to refresh the image tag after every 3 seconds. Thoughts? – Arjun Feb 16 '17 at 19:58
2

To show a page as a dialog box its probably something like this:

var D = new ContentDialog {
    Title = "MyPage",
    Content = new MyUserControl()
};

var T = D.ShowAsync();

Most examples of ContentDialog show Content set to a string, however Content can be set to any UIElement including a UserControl.

In above example, place your page inside of a UserControl:

<UserControl …>
    <StackPanel>
         …
    </StackPanel>
</UserControl>

You get the idea...

Bimo
  • 5,987
  • 2
  • 39
  • 61