ContentDialog Universal Windows Program: Part 1

ContentDialog is used to create a user-defined Modal Dialog,

Modal dialog:
It force the user to get the input (whether is success or failure) until user cannot interact with Parent windows, Modal dialog is called child dialog.

Example: VS - Account Settings, then Enter the product key dialog (Modal Dialog), without close this dialog, user cannot interact with the parent dialogue,

visual

In Universal Windows Program we can create a content dialog in two different ways,

  1. Create a content dialog in code behind page.
  2. Create in XMAL page.

Code behind page

Use the ContentDialog class to create dialog & default it has two buttons, primary & secondary buttons, All the default texts are customizable, like Title, content, PrimaryButtonText, SecondaryButtonText.

Example

ex

Show the dialog using the ShowAsync function,

ShowAsync

Content dialog return the result as ContentDialogResult,

ContentDialogResult
Return the values,

values 

Output

FullSizeDesired: Property used for displaying content dialog in full screen.

So far we have seen, this control looks like Message Box, now we are going to see how to add other controls in this dialog,

You can see the content property is object so we can assign any object to this property.

Example: Add the textbox into this content,

ex

content

Read the value from the text,

text

Next article, we will see how to handle content dialog in XAML page.

Up Next
    Ebook Download
    View all
    Learn
    View all