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,
In Universal Windows Program we can create a content dialog in two different ways,
- Create a content dialog in code behind page.
- 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
Show the dialog using the ShowAsync function,
Content dialog return the result as ContentDialogResult,
Return the 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,
Read the value from the text,
Next article, we will see how to handle content dialog in XAML page.