Content​Dialog Content​Dialog Content​Dialog Content​Dialog Class

Definition

Some information relates to pre-released product which may be substantially modified before it’s commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Prerelease APIs are identified by a Prerelease label.

[Contains prerelease APIs.]
Represents a dialog box that can be customized to contain checkboxes, hyperlinks, buttons and any other XAML content.

public : class ContentDialog : ContentControl, IContentDialog, IContentDialog2public class ContentDialog : ContentControl, IContentDialog, IContentDialog2Public Class ContentDialog Inherits ContentControl Implements IContentDialog, IContentDialog2// This API is not available in Javascript.
<ContentDialog .../>
-or-
<ContentDialog>
    singleObject
</ContentDialog>
-or-
<ContentDialog>stringContent</ContentDialog>
Inheritance
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Inherited Members

Inherited properties

Inherited events

Inherited methods

Examples

This example shows how to create and show a simple ContentDialog in code.

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

    await noWifiDialog.ShowAsync();
}

This example shows how to create a ContentDialog in the XAML of an app page. Even though the dialog is defined in the app page, it's not shown until you call ShowAsync in your code.

Here, the IsPrimaryButtonEnabled property is set to false. The primary button is enabled in code when the user checks the CheckBox to confirm their age.

The TitleTemplate property is used to create a title that includes both a logo and text.

<ContentDialog x:Name="termsOfUseContentDialog"
           PrimaryButtonText="Accept" IsPrimaryButtonEnabled="False"
           CloseButtonText="Cancel"
           Opened="TermsOfUseContentDialog_Opened">
    <ContentDialog.TitleTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <Image Source="ms-appx:///Assets/SmallLogo.png" Width="40" Height="40" Margin="10,0"/>
                <TextBlock Text="Terms of use"/>
            </StackPanel>
        </DataTemplate>
    </ContentDialog.TitleTemplate>
    <StackPanel>
        <TextBlock TextWrapping="WrapWholeWords">
        <Run>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor
             congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus
             malesuada libero, sit amet commodo magna eros quis urna.</Run><LineBreak/>
        <Run>Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus.</Run><LineBreak/>
        <Run>Pellentesque habitant morbi tristique senectus et netus et malesuada fames
             ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.</Run><LineBreak/>
        <Run>Suspendisse dui purus, scelerisque at, vulputate vitae, pretium mattis, nunc.
             Mauris eget neque at sem venenatis eleifend. Ut nonummy.</Run>
        </TextBlock>
        <CheckBox x:Name="ConfirmAgeCheckBox" Content="I am over 13 years of age."
              Checked="ConfirmAgeCheckBox_Checked" Unchecked="ConfirmAgeCheckBox_Unchecked"/>
    </StackPanel>
</ContentDialog>
private async void ShowTermsOfUseContentDialogButton_Click(object sender, RoutedEventArgs e)
{
    ContentDialogResult result = await termsOfUseContentDialog.ShowAsync();
    if (result == ContentDialogResult.Primary)
    {
        // Terms of use were accepted.
    }
    else
    {
        // User pressed Cancel, ESC, or the back arrow.
        // Terms of use were not accepted.
    }
}

private void TermsOfUseContentDialog_Opened(ContentDialog sender, ContentDialogOpenedEventArgs args)
{
    // Ensure that the check box is unchecked each time the dialog opens.
    ConfirmAgeCheckBox.IsChecked = false;
}

private void ConfirmAgeCheckBox_Checked(object sender, RoutedEventArgs e)
{
    termsOfUseContentDialog.IsPrimaryButtonEnabled = true;
}

private void ConfirmAgeCheckBox_Unchecked(object sender, RoutedEventArgs e)
{
    termsOfUseContentDialog.IsPrimaryButtonEnabled = false;
}

This example shows how to create and use a custom dialog (SignInContentDialog) derived from ContentDialog.


<!-- SignInContentDialog.xaml -->
<ContentDialog
    x:Class="ExampleApp.SignInContentDialog"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:ExampleApp"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Title="SIGN IN"
    PrimaryButtonText="Sign In"  
    CloseButtonText="Cancel"
    PrimaryButtonClick="ContentDialog_PrimaryButtonClick"
    CloseButtonClick="ContentDialog_CloseButtonClick">

    <ContentDialog.Resources>
    <!-- These flyouts or used for confirmation when the user changes
         the option to save their user name. -->
        <Flyout x:Key="DiscardNameFlyout" Closed="Flyout_Closed">
            <StackPanel>
                <TextBlock Text="Discard user name?"/>
                <Button Content="Discard" Click="DiscardButton_Click"/>
            </StackPanel>
        </Flyout>
        <Flyout x:Key="SaveNameFlyout" Closed="Flyout_Closed">
            <StackPanel>
                <TextBlock Text="Save user name?"/>
                <Button Content="Save" Click="SaveButton_Click"/>
            </StackPanel>
        </Flyout>
    </ContentDialog.Resources>

    <StackPanel VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
        <TextBox Name="userNameTextBox" Header="User name"/>
        <PasswordBox Name="passwordTextBox" Header="Password" IsPasswordRevealButtonEnabled="True"/>
        <CheckBox Name="saveUserNameCheckBox" Content="Save user name"/>

        <TextBlock x:Name="errorTextBlock" Style="{StaticResource ControlContextualInfoTextBlockStyle}"/>

        <!-- Content body -->
        <TextBlock Name="body" Style="{StaticResource MessageDialogContentStyle}" TextWrapping="Wrap">
            <TextBlock.Text>
                Lorem ipsum dolor sit amet, consectetur adipisicing elit,
                    sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
            </TextBlock.Text>
        </TextBlock>
    </StackPanel>
</ContentDialog>

// SignInContentDialog.xaml.cs
using System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;

namespace ExampleApp
{
    public enum SignInResult
    {
        SignInOK,
        SignInFail,
        SignInCancel,
        Nothing
    }

    public sealed partial class SignInContentDialog : ContentDialog
    {
        public SignInResult Result { get; private set; }

        public SignInContentDialog()
        {
            this.InitializeComponent();
            this.Opened += SignInContentDialog_Opened;
            this.Closing += SignInContentDialog_Closing;
        }

        private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            // Ensure the user name and password fields aren't empty. If a required field
            // is empty, set args.Cancel = true to keep the dialog open.
            if (string.IsNullOrEmpty(userNameTextBox.Text))
            {
                args.Cancel = true;
                errorTextBlock.Text = "User name is required.";
            }
            else if (string.IsNullOrEmpty(passwordTextBox.Password))
            {
                args.Cancel = true;
                errorTextBlock.Text = "Password is required.";
            }

            // If you're performing async operations in the button click handler,
            // get a deferral before you await the operation. Then, complete the
            // deferral when the async operation is complete.

            ContentDialogButtonClickDeferral deferral = args.GetDeferral();    
            if (await SomeAsyncSignInOperation())
            {
                this.Result = SignInResult.SignInOK;
            }
            else
            {
                this.Result = SignInResult.SignInFail;
            }
            deferral.Complete();
        }

        private void ContentDialog_CloseButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            // User clicked Cancel, ESC, or the system back button.
            this.Result = SignInResult.SignInCancel;
        }

        void SignInContentDialog_Opened(ContentDialog sender, ContentDialogOpenedEventArgs args)
        {
            this.Result = SignInResult.Nothing;

            // If the user name is saved, get it and populate the user name field.
            Windows.Storage.ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings;
            if (roamingSettings.Values.ContainsKey("userName"))
            {
                userNameTextBox.Text = roamingSettings.Values["userName"].ToString();
                saveUserNameCheckBox.IsChecked = true;
            }
        }

        void SignInContentDialog_Closing(ContentDialog sender, ContentDialogClosingEventArgs args)
        {
            // If sign in was successful, save or clear the user name based on the user choice.
            if (this.Result == SignInResult.SignInOK)
            {
                if (saveUserNameCheckBox.IsChecked == true)
                {
                    SaveUserName();
                }
                else
                {
                    ClearUserName();
                }
            }

            // If the user entered a name and checked or cleared the 'save user name' checkbox, then clicked the back arrow,
            // confirm if it was their intention to save or clear the user name without signing in.
            if (this.Result == SignInResult.Nothing && !string.IsNullOrEmpty(userNameTextBox.Text))
            {
                if (saveUserNameCheckBox.IsChecked == false)
                {
                    args.Cancel = true;
                    FlyoutBase.SetAttachedFlyout(this, (FlyoutBase)this.Resources["DiscardNameFlyout"]);
                    FlyoutBase.ShowAttachedFlyout(this);
                }
                else if (saveUserNameCheckBox.IsChecked == true && !string.IsNullOrEmpty(userNameTextBox.Text))
                {
                    args.Cancel = true;
                    FlyoutBase.SetAttachedFlyout(this, (FlyoutBase)this.Resources["SaveNameFlyout"]);
                    FlyoutBase.ShowAttachedFlyout(this);
                }
            }
        }

        private void SaveUserName()
        {
            Windows.Storage.ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings;
            roamingSettings.Values["userName"] = userNameTextBox.Text;
        }

        private void ClearUserName()
        {
            Windows.Storage.ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings;
            roamingSettings.Values["userName"] = null;
            userNameTextBox.Text = string.Empty;
        }

        // Handle the button clicks from the flyouts.
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            SaveUserName();
            FlyoutBase.GetAttachedFlyout(this).Hide();
        }

        private void DiscardButton_Click(object sender, RoutedEventArgs e)
        {
            ClearUserName();
            FlyoutBase.GetAttachedFlyout(this).Hide();
        }

        // When the flyout closes, hide the sign in dialog, too.
        private void Flyout_Closed(object sender, object e)
        {
            this.Hide();
        }
    }
}

Here's code that shows the SignInContentDialog and uses it's custom SignInResult.


private async void ShowSignInDialogButton_Click(object sender, RoutedEventArgs e)
{
    SignInContentDialog signInDialog = new SignInContentDialog();
    await signInDialog.ShowAsync();

    if (signInDialog.Result == SignInResult.SignInOK)
    {
        // Sign in was successful.
    }
    else if (signInDialog.Result == SignInResult.SignInFail)
    {
        // Sign in failed.
    }
    else if (signInDialog.Result == SignInResult.SignInCancel)
    {
        // Sign in was cancelled by the user.
    }
}

Remarks

Use a ContentDialog to request input from the user, or to show information in a modal dialog. You can add a ContentDialog to an app page using code or XAML, or you can create a custom dialog class that's derived from ContentDialog. Both ways are shown in the examples section of this topic.

Use the Title property to put a title on the dialog. To add a complex title element with more than simple text, you can use the TitleTemplate property.

The ContentDialog has 3 built-in buttons that describe the actions that the user may take in response to the dialog's prompt. All dialogs should have a safe, non-destructive action. Dialogs may also optionally contain one or two specific "do it" actions in response to the prompt.

Use the CloseButtonText and property to set the display text for the safe, non-destructive button. The dialog's close button will also be invoked when the user performs a Cancel action, like pressing the ESC key or pressing the system back button. Use the PrimaryButtonText and SecondaryButtonText properties to display responses to the main question or action posed by the dialog.

The CloseButtonText property is not available prior to Windows 10, version 1703. If your app’s 'minimum platform version' setting in Microsoft Visual Studio is less than the 'introduced version' shown in the Requirements block later in this page, you should use the SecondaryButtonText property instead. For more info, see Version adaptive code.

To show the dialog, call the ShowAsync method. Use the result of this method to determine which of the buttons was clicked, if any button was clicked. If the user presses ESC, the system back arrow, or Gamepad B, the result of this method will be None.

You may optionally choose to differentiate one of the three buttons as the dialog's default button. Use the DefaultButton property to differentiate one of the buttons. This button will receive the Accent Button visual treatment, respond to the ENTER key automatically, and receive focus when the Dialog is opened unless the dialog's content contains focusable elements.

You may wish to do some work before the dialog closes (for example, to verify that the user entered into form fields before submitting a request). You have two ways to do work before the dialog closes. You can handle the PrimaryButtonClick, SecondaryButtonClick, or CloseButtonClick events to get the user's response when the user presses a button and verify the state of the dialog before it closes. You can also handle the Closing event to do work before the dialog closes.

Only one ContentDialog can be shown at a time. To chain together more than one ContentDialog, handle the Closing event of the first ContentDialog. In the Closing event handler, call ShowAsync on the second dialog to show it.

Control style and template

You can modify the default Style and ControlTemplate to give the control a unique appearance. For information about modifying a control's style and template, see Styling controls. The default style, template, and resources that define the look of the control are included in the generic.xaml file. For design purposes, generic.xaml is available in the (Program Files)\Windows Kits\10\DesignTime\CommonConfiguration\Neutral\UAP&lt;SDK version>\Generic folder from a Windows Software Development Kit (SDK) installation. Styles and resources from different versions of the SDK might have different values.

Starting in Windows 10, version 1607 (Windows Software Development Kit (SDK) version 10.0.14393.0), generic.xaml includes resources that you can use to modify the colors of a control in different visual states without modifying the control template. In apps that target this software development kit (SDK) or later, modifying these resources is preferred to setting properties such as Background and Foreground. For more info, see the Light-weight styling section of the Styling controls article.

This table shows the resources used by the ContentDialog control.

Resource keyDescription
ContentDialogForegroundText color in dialog
ContentDialogBackgroundBackground color
ContentDialogBorderBrushBorder color

Constructors

ContentDialog() ContentDialog() ContentDialog() ContentDialog()

Initializes a new instance of the ContentDialog class.

public : ContentDialog()public ContentDialog()Public Sub New()// This API is not available in Javascript.

Properties

CloseButtonCommand CloseButtonCommand CloseButtonCommand CloseButtonCommand

Gets or sets the command to invoke when the close button is tapped.

public : ICommand CloseButtonCommand { get; set; }public ICommand CloseButtonCommand { get; set; }Public ReadWrite Property CloseButtonCommand As ICommand// This API is not available in Javascript.
<ContentDialog CloseButtonCommand="commandReference"/>

Value
ICommand ICommand ICommand ICommand

The command to invoke when the primary button is tapped.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

CloseButtonCommandParameter CloseButtonCommandParameter CloseButtonCommandParameter CloseButtonCommandParameter

Gets or sets the parameter to pass to the command for the close button.

public : PlatForm::Object CloseButtonCommandParameter { get; set; }public object CloseButtonCommandParameter { get; set; }Public ReadWrite Property CloseButtonCommandParameter As object// This API is not available in Javascript.
<ContentDialog>

  <ContentDialog.CloseButtonCommandParameter>

    object

  </ContentDialog.CloseButtonCommandParameter>

</ContentDialog>

Value
PlatForm::Object object object object

The parameter to pass to the command for the close button. The default is null.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

CloseButtonCommandParameterProperty CloseButtonCommandParameterProperty CloseButtonCommandParameterProperty CloseButtonCommandParameterProperty

Gets the identifier of the CloseButtonCommandParameter dependency property.

public : static DependencyProperty CloseButtonCommandParameterProperty { get; }public static DependencyProperty CloseButtonCommandParameterProperty { get; }Public Static ReadOnly Property CloseButtonCommandParameterProperty As DependencyProperty// This API is not available in Javascript.
Value
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

The identifier of the CloseButtonCommandParameter dependency property.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

CloseButtonCommandProperty CloseButtonCommandProperty CloseButtonCommandProperty CloseButtonCommandProperty

Gets the identifier of the CloseButtonCommand dependency property.

public : static DependencyProperty CloseButtonCommandProperty { get; }public static DependencyProperty CloseButtonCommandProperty { get; }Public Static ReadOnly Property CloseButtonCommandProperty As DependencyProperty// This API is not available in Javascript.
Value
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

The identifier of the CloseButtonCommand dependency property.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

CloseButtonStyle CloseButtonStyle CloseButtonStyle CloseButtonStyle

Gets or sets the Style to apply to the dialog's close button.

public : Style CloseButtonStyle { get; set; }public Style CloseButtonStyle { get; set; }Public ReadWrite Property CloseButtonStyle As Style// This API is not available in Javascript.
<contentDialog CloseButtonStyle="{StaticResource styleResourceKey}"//>
Value
Style Style Style Style

The applied style for the button, if present; otherwise, null.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

CloseButtonStyleProperty CloseButtonStyleProperty CloseButtonStyleProperty CloseButtonStyleProperty

Gets the identifier of the CloseButtonStyle dependency property.

public : static DependencyProperty CloseButtonStyleProperty { get; }public static DependencyProperty CloseButtonStyleProperty { get; }Public Static ReadOnly Property CloseButtonStyleProperty As DependencyProperty// This API is not available in Javascript.
Value
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

The identifier of the CloseButtonStyle dependency property.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

CloseButtonText CloseButtonText CloseButtonText CloseButtonText

Gets or sets the text to display on the close button.

public : PlatForm::String CloseButtonText { get; set; }public string CloseButtonText { get; set; }Public ReadWrite Property CloseButtonText As string// This API is not available in Javascript.
<ContentDialog CloseButtonText="string"/>

Value
PlatForm::String string string string

The text to display on the close button.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Remarks

Every dialog should contain a safe, nondestructive action button that enables the user to confidently exit the dialog.

Use the close button to create this button. This allows you to create the right user experience for all inputs including mouse, keyboard, touch, and gamepad. The dialog will close when:

  • The user clicks or taps on the close button
  • The user presses the system back button
  • The user presses the ESC button on keyboard
  • The user presses Gamepad B

Invoking the close button returns ContentDialogResult.None.

Version compatibility

The CloseButtonText property is not available prior to Windows 10, version 1703. If your app’s 'minimum platform version' setting in Microsoft Visual Studio is less than the 'introduced version' shown in the Requirements block later in this page, you should use the SecondaryButtonText property instead. For more info, see Version adaptive code.

To avoid exceptions when your app runs on previous versions of Windows 10, do not set this property in XAML or use it without performing a runtime check. This example shows how to use the ApiInformation class to check for the presence of this property before you set it.

<ContentDialog x:Name="contentDialog1" Loaded="ContentDialog_Loaded">

    ...

</ContentDialog>
private void ContentDialog_Loaded(object sender, RoutedEventArgs e)
{

    if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.ContentDialog", "CloseButtonText"))

    {

        contentDialog1.CloseButtonText = "Cancel";

    }

    else

    {

        contentDialog1.SecondaryButtonText = "Cancel";

    }

}

CloseButtonTextProperty CloseButtonTextProperty CloseButtonTextProperty CloseButtonTextProperty

Gets the identifier of the CloseButtonText dependency property.

public : static DependencyProperty CloseButtonTextProperty { get; }public static DependencyProperty CloseButtonTextProperty { get; }Public Static ReadOnly Property CloseButtonTextProperty As DependencyProperty// This API is not available in Javascript.
Value
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

The identifier of the CloseButtonText dependency property.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

DefaultButton DefaultButton DefaultButton DefaultButton

Gets or sets a value that indicates which button on the dialog is the default action.

public : ContentDialogButton DefaultButton { get; set; }public ContentDialogButton DefaultButton { get; set; }Public ReadWrite Property DefaultButton As ContentDialogButton// This API is not available in Javascript.
Value
ContentDialogButton ContentDialogButton ContentDialogButton ContentDialogButton

A value of the enumeration. The default is None.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Remarks

You may optionally choose to differentiate one of the three buttons as the default button. Specifying the default button causes the following to happen:

  • The button receives the Accent Button visual treatment
  • The button will respond to the ENTER key automatically
    • When the user presses the ENTER key on the keyboard, the click handler associated with the default button will fire and the ContentDialogResult will return the value associated with the default button
    • If the user has placed focus on a control that handles ENTER, the default button will not respond to ENTER presses
  • The button will receive focus automatically when the dialog is opened unless the dialog’s content contains focusable UI

Version compatibility

The DefaultButton property is not available prior to Windows 10, version 1703. If your app’s 'minimum platform version' setting in Microsoft Visual Studio is less than the 'introduced version' shown in the Requirements block later in this page, you must design and test your app to account for this. For more info, see Version adaptive code.

To avoid exceptions when your app runs on previous versions of Windows 10, do not set this property in XAML or use it without performing a runtime check. This example shows how to use the ApiInformation class to check for the presence of this property before you set it.

<ContentDialog x:Name="contentDialog1" Loaded="ContentDialog_Loaded">
    ...
</ContentDialog>
private void ContentDialog_Loaded(object sender, RoutedEventArgs e)
{
    if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.ContentDialog", "DefaultButton"))
    {
        contentDialog1.DefaultButton = ContentDialogButton.Primary;
    }
}

DefaultButtonProperty DefaultButtonProperty DefaultButtonProperty DefaultButtonProperty

Gets the identifier of the DefaultButton dependency property.

public : static DependencyProperty DefaultButtonProperty { get; }public static DependencyProperty DefaultButtonProperty { get; }Public Static ReadOnly Property DefaultButtonProperty As DependencyProperty// This API is not available in Javascript.
Value
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

The identifier of the DefaultButton dependency property.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

FullSizeDesired FullSizeDesired FullSizeDesired FullSizeDesired

Gets or sets a value that indicates whether a request is being made to display the dialog full screen.

public : PlatForm::Boolean FullSizeDesired { get; set; }public bool FullSizeDesired { get; set; }Public ReadWrite Property FullSizeDesired As bool// This API is not available in Javascript.
<ContentDialog FullSizeDesired="bool"/>
Value
PlatForm::Boolean bool bool bool

true to request that the dialog is displayed full screen; otherwise, false. The default is false.

FullSizeDesiredProperty FullSizeDesiredProperty FullSizeDesiredProperty FullSizeDesiredProperty

Gets the identifier of the FullSizeDesired dependency property.

public : static DependencyProperty FullSizeDesiredProperty { get; }public static DependencyProperty FullSizeDesiredProperty { get; }Public Static ReadOnly Property FullSizeDesiredProperty As DependencyProperty// This API is not available in Javascript.
Value
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

The identifier of the FullSizeDesired dependency property.

IsPrimaryButtonEnabled IsPrimaryButtonEnabled IsPrimaryButtonEnabled IsPrimaryButtonEnabled

Gets or sets whether the dialog's primary button is enabled.

public : PlatForm::Boolean IsPrimaryButtonEnabled { get; set; }public bool IsPrimaryButtonEnabled { get; set; }Public ReadWrite Property IsPrimaryButtonEnabled As bool// This API is not available in Javascript.
<ContentDialog IsPrimaryButtonEnabled="bool"/>
Value
PlatForm::Boolean bool bool bool

True if the primary button of the dialog is enabled; Otherwise, false.

IsPrimaryButtonEnabledProperty IsPrimaryButtonEnabledProperty IsPrimaryButtonEnabledProperty IsPrimaryButtonEnabledProperty

Gets the identifier of the IsPrimaryButtonEnabled dependency property.

public : static DependencyProperty IsPrimaryButtonEnabledProperty { get; }public static DependencyProperty IsPrimaryButtonEnabledProperty { get; }Public Static ReadOnly Property IsPrimaryButtonEnabledProperty As DependencyProperty// This API is not available in Javascript.

IsSecondaryButtonEnabled IsSecondaryButtonEnabled IsSecondaryButtonEnabled IsSecondaryButtonEnabled

Gets or sets whether the dialog's secondary button is enabled.

public : PlatForm::Boolean IsSecondaryButtonEnabled { get; set; }public bool IsSecondaryButtonEnabled { get; set; }Public ReadWrite Property IsSecondaryButtonEnabled As bool// This API is not available in Javascript.
<ContentDialog IsSecondaryButtonEnabled="bool"/>
Value
PlatForm::Boolean bool bool bool

True if the secondary button of the dialog is enabled; Otherwise, false.

IsSecondaryButtonEnabledProperty IsSecondaryButtonEnabledProperty IsSecondaryButtonEnabledProperty IsSecondaryButtonEnabledProperty

Gets the identifier of the IsSecondaryButtonEnabled dependency property.

public : static DependencyProperty IsSecondaryButtonEnabledProperty { get; }public static DependencyProperty IsSecondaryButtonEnabledProperty { get; }Public Static ReadOnly Property IsSecondaryButtonEnabledProperty As DependencyProperty// This API is not available in Javascript.

PrimaryButtonCommand PrimaryButtonCommand PrimaryButtonCommand PrimaryButtonCommand

Gets or sets the command to invoke when the primary button is tapped.

public : ICommand PrimaryButtonCommand { get; set; }public ICommand PrimaryButtonCommand { get; set; }Public ReadWrite Property PrimaryButtonCommand As ICommand// This API is not available in Javascript.
<ContentDialog PrimaryButtonCommand="commandReference"/>
Value
ICommand ICommand ICommand ICommand

The command to invoke when the primary button is tapped.

PrimaryButtonCommandParameter PrimaryButtonCommandParameter PrimaryButtonCommandParameter PrimaryButtonCommandParameter

Gets or sets the parameter to pass to the command for the primary button.

public : PlatForm::Object PrimaryButtonCommandParameter { get; set; }public object PrimaryButtonCommandParameter { get; set; }Public ReadWrite Property PrimaryButtonCommandParameter As object// This API is not available in Javascript.
<ContentDialog>
  <ContentDialog.PrimaryButtonCommandParameter>
    object
  </ContentDialog.PrimaryButtonCommandParameter>
</ContentDialog>
Value
PlatForm::Object object object object

The parameter to pass to the command for the primary button. The default is null.

PrimaryButtonCommandParameterProperty PrimaryButtonCommandParameterProperty PrimaryButtonCommandParameterProperty PrimaryButtonCommandParameterProperty

Gets the identifier of the PrimaryButtonCommandParameter dependency property.

public : static DependencyProperty PrimaryButtonCommandParameterProperty { get; }public static DependencyProperty PrimaryButtonCommandParameterProperty { get; }Public Static ReadOnly Property PrimaryButtonCommandParameterProperty As DependencyProperty// This API is not available in Javascript.
Value
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

The identifier of the PrimaryButtonCommandParameter dependency property

PrimaryButtonCommandProperty PrimaryButtonCommandProperty PrimaryButtonCommandProperty PrimaryButtonCommandProperty

Gets the identifier of the PrimaryButtonCommand dependency property.

public : static DependencyProperty PrimaryButtonCommandProperty { get; }public static DependencyProperty PrimaryButtonCommandProperty { get; }Public Static ReadOnly Property PrimaryButtonCommandProperty As DependencyProperty// This API is not available in Javascript.
Value
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

The identifier of the PrimaryButtonCommand dependency property.

PrimaryButtonStyle PrimaryButtonStyle PrimaryButtonStyle PrimaryButtonStyle

Gets or sets the Style to apply to the dialog's primary button.

public : Style PrimaryButtonStyle { get; set; }public Style PrimaryButtonStyle { get; set; }Public ReadWrite Property PrimaryButtonStyle As Style// This API is not available in Javascript.
<contentDialog CloseButtonStyle="{StaticResource styleResourceKey}"//>
Value
Style Style Style Style

The applied style for the button, if present; otherwise, null.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

PrimaryButtonStyleProperty PrimaryButtonStyleProperty PrimaryButtonStyleProperty PrimaryButtonStyleProperty

Gets the identifier of the PrimaryButtonStyle dependency property.

public : static DependencyProperty PrimaryButtonStyleProperty { get; }public static DependencyProperty PrimaryButtonStyleProperty { get; }Public Static ReadOnly Property PrimaryButtonStyleProperty As DependencyProperty// This API is not available in Javascript.
Value
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

The identifier of the PrimaryButtonStyle dependency property.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

PrimaryButtonText PrimaryButtonText PrimaryButtonText PrimaryButtonText

Gets or sets the text to display on the primary button.

public : PlatForm::String PrimaryButtonText { get; set; }public string PrimaryButtonText { get; set; }Public ReadWrite Property PrimaryButtonText As string// This API is not available in Javascript.
<ContentDialog PrimaryButtonText="string"/>
Value
PlatForm::String string string string

The text to display on the primary button. To hide this button, set the text to null or string.empty. The default is empty.

PrimaryButtonTextProperty PrimaryButtonTextProperty PrimaryButtonTextProperty PrimaryButtonTextProperty

Gets the identifier of the PrimaryButtonText dependency property.

public : static DependencyProperty PrimaryButtonTextProperty { get; }public static DependencyProperty PrimaryButtonTextProperty { get; }Public Static ReadOnly Property PrimaryButtonTextProperty As DependencyProperty// This API is not available in Javascript.
Value
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

The identifier of the PrimaryButtonText dependency property.

SecondaryButtonCommand SecondaryButtonCommand SecondaryButtonCommand SecondaryButtonCommand

Gets or sets the command to invoke when the secondary button is tapped.

public : ICommand SecondaryButtonCommand { get; set; }public ICommand SecondaryButtonCommand { get; set; }Public ReadWrite Property SecondaryButtonCommand As ICommand// This API is not available in Javascript.
<ContentDialog SecondaryButtonCommand="commandReference"/>
Value
ICommand ICommand ICommand ICommand

The command to invoke when the secondary button is tapped.

SecondaryButtonCommandParameter SecondaryButtonCommandParameter SecondaryButtonCommandParameter SecondaryButtonCommandParameter

Gets or sets the parameter to pass to the command for the secondary button.

public : PlatForm::Object SecondaryButtonCommandParameter { get; set; }public object SecondaryButtonCommandParameter { get; set; }Public ReadWrite Property SecondaryButtonCommandParameter As object// This API is not available in Javascript.
<ContentDialog>
  <ContentDialog.SecondaryButtonCommandParameter>
    object
  </ContentDialog.SecondaryButtonCommandParameter>
</ContentDialog>
Value
PlatForm::Object object object object

The command parameter for the secondary button. The default is null.

SecondaryButtonCommandParameterProperty SecondaryButtonCommandParameterProperty SecondaryButtonCommandParameterProperty SecondaryButtonCommandParameterProperty

Gets the identifier of the SecondaryButtonCommandParameter dependency property.

public : static DependencyProperty SecondaryButtonCommandParameterProperty { get; }public static DependencyProperty SecondaryButtonCommandParameterProperty { get; }Public Static ReadOnly Property SecondaryButtonCommandParameterProperty As DependencyProperty// This API is not available in Javascript.
Value
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

The identifier of the SecondaryButtonCommandParameter dependency property.

SecondaryButtonCommandProperty SecondaryButtonCommandProperty SecondaryButtonCommandProperty SecondaryButtonCommandProperty

Gets the identifier of the SecondaryButtonCommand dependency property.

public : static DependencyProperty SecondaryButtonCommandProperty { get; }public static DependencyProperty SecondaryButtonCommandProperty { get; }Public Static ReadOnly Property SecondaryButtonCommandProperty As DependencyProperty// This API is not available in Javascript.
Value
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

The identifier of the SecondaryButtonCommand dependency property.

SecondaryButtonStyle SecondaryButtonStyle SecondaryButtonStyle SecondaryButtonStyle

Gets or sets the Style to apply to the dialog's secondary button.

public : Style SecondaryButtonStyle { get; set; }public Style SecondaryButtonStyle { get; set; }Public ReadWrite Property SecondaryButtonStyle As Style// This API is not available in Javascript.
<contentDialog CloseButtonStyle="{StaticResource styleResourceKey}"//>
Value
Style Style Style Style

The applied style for the button, if present; otherwise, null.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

SecondaryButtonStyleProperty SecondaryButtonStyleProperty SecondaryButtonStyleProperty SecondaryButtonStyleProperty

Gets the identifier of the SecondaryButtonStyle dependency property.

public : static DependencyProperty SecondaryButtonStyleProperty { get; }public static DependencyProperty SecondaryButtonStyleProperty { get; }Public Static ReadOnly Property SecondaryButtonStyleProperty As DependencyProperty// This API is not available in Javascript.
Value
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

The identifier of the SecondaryButtonStyle dependency property.

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

SecondaryButtonText SecondaryButtonText SecondaryButtonText SecondaryButtonText

Gets or sets the text to be displayed on the secondary button.

public : PlatForm::String SecondaryButtonText { get; set; }public string SecondaryButtonText { get; set; }Public ReadWrite Property SecondaryButtonText As string// This API is not available in Javascript.
<ContentDialog SecondaryButtonText="string"/>
Value
PlatForm::String string string string

The text to be displayed on the secondary button. To hide this button, set the value to null or string.empty.

SecondaryButtonTextProperty SecondaryButtonTextProperty SecondaryButtonTextProperty SecondaryButtonTextProperty

Gets the identifier of the SecondaryButtonText dependency property.

public : static DependencyProperty SecondaryButtonTextProperty { get; }public static DependencyProperty SecondaryButtonTextProperty { get; }Public Static ReadOnly Property SecondaryButtonTextProperty As DependencyProperty// This API is not available in Javascript.
Value
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

The identifier of the SecondaryButtonText dependency property.

Title Title Title Title

Gets or sets the title of the dialog.

public : PlatForm::Object Title { get; set; }public object Title { get; set; }Public ReadWrite Property Title As object// This API is not available in Javascript.
<ContentDialog Title="string"/>

Value
PlatForm::Object object object object

The title of the dialog.

TitleProperty TitleProperty TitleProperty TitleProperty

Gets the identifier of the Title dependency property.

public : static DependencyProperty TitleProperty { get; }public static DependencyProperty TitleProperty { get; }Public Static ReadOnly Property TitleProperty As DependencyProperty// This API is not available in Javascript.
Value
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

The identifier of the Title dependency property.

TitleTemplate TitleTemplate TitleTemplate TitleTemplate

Gets or sets the title template.

public : DataTemplate TitleTemplate { get; set; }public DataTemplate TitleTemplate { get; set; }Public ReadWrite Property TitleTemplate As DataTemplate// This API is not available in Javascript.
<ContentDialog>
  <ContentDialog.TitleTemplate>
    singleDataTemplate
  </ContentDialog.TitleTemplate>
</ContentDialog>

TitleTemplateProperty TitleTemplateProperty TitleTemplateProperty TitleTemplateProperty

Gets the identifier of the TitleTemplate dependency property.

public : static DependencyProperty TitleTemplateProperty { get; }public static DependencyProperty TitleTemplateProperty { get; }Public Static ReadOnly Property TitleTemplateProperty As DependencyProperty// This API is not available in Javascript.
Value
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

The identifier of the TitleTemplate dependency property.

Methods

Hide() Hide() Hide() Hide()

Hides the dialog.

public : void Hide()public void Hide()Public Function Hide() As void// This API is not available in Javascript.

ShowAsync() ShowAsync() ShowAsync() ShowAsync()

Begins an asynchronous operation to show the dialog.

public : IAsyncOperation<ContentDialogResult> ShowAsync()public IAsyncOperation<ContentDialogResult> ShowAsync()Public Function ShowAsync() As IAsyncOperation( Of ContentDialogResult )// This API is not available in Javascript.
Returns

ShowAsync(ContentDialogPlacement) ShowAsync(ContentDialogPlacement) ShowAsync(ContentDialogPlacement) ShowAsync(ContentDialogPlacement)

Prerelease. Begins an asynchronous operation to show the dialog with the specified placement.

public : IAsyncOperation<ContentDialogResult> ShowAsync(ContentDialogPlacement placement)public IAsyncOperation<ContentDialogResult> ShowAsync(ContentDialogPlacement placement)Public Function ShowAsync(placement As ContentDialogPlacement) As IAsyncOperation( Of ContentDialogResult )// This API is not available in Javascript.
Parameters
placement
ContentDialogPlacement ContentDialogPlacement ContentDialogPlacement ContentDialogPlacement

A value that specifies whether the dialog is placed in the PopupRoot or in its parent's visual tree.

Returns
Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.16225.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v5)

Remarks

When you call this method with the ContentDialogPlacement.Popup parameter value, the dialog is rooted in the PopupRoot element of the XAML Window. This is the default behavior, and is equivilent to calling the ShowAsync method with no parameters.

When you call this method with the ContentDialogPlacement.InPlace parameter value:

  • If the dialog has a parent element, the dialog is rooted in the parent's visual tree. It's shown inline along with the parent’s other child elements, and participates in the parent container’s layout.
  • If the dialog has no parent, the dialog falls back to the default behavior and is shown in the PopupRoot.

Events

CloseButtonClick CloseButtonClick CloseButtonClick CloseButtonClick

Occurs after the close button has been tapped.

public : event TypedEventHandler CloseButtonClick<ContentDialog,  ContentDialogButtonClickEventArgs>public event TypedEventHandler CloseButtonClick<ContentDialog,  ContentDialogButtonClickEventArgs>Public Event CloseButtonClick<ContentDialog,  ContentDialogButtonClickEventArgs>// This API is not available in Javascript.
<ContentDialog CloseButtonClick="eventhandler"/>

Additional features and requirements
Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

Closed Closed Closed Closed

Occurs after the dialog is closed.

public : event TypedEventHandler Closed<ContentDialog,  ContentDialogClosedEventArgs>public event TypedEventHandler Closed<ContentDialog,  ContentDialogClosedEventArgs>Public Event Closed<ContentDialog,  ContentDialogClosedEventArgs>// This API is not available in Javascript.
<ContentDialog Closed="eventhandler"/>

Closing Closing Closing Closing

Occurs after the dialog starts to close, but before it is closed and before the Closed event occurs.

public : event TypedEventHandler Closing<ContentDialog,  ContentDialogClosingEventArgs>public event TypedEventHandler Closing<ContentDialog,  ContentDialogClosingEventArgs>Public Event Closing<ContentDialog,  ContentDialogClosingEventArgs>// This API is not available in Javascript.
<ContentDialog Closing="eventhandler"/>

Opened Opened Opened Opened

Occurs after the dialog is opened.

public : event TypedEventHandler Opened<ContentDialog,  ContentDialogOpenedEventArgs>public event TypedEventHandler Opened<ContentDialog,  ContentDialogOpenedEventArgs>Public Event Opened<ContentDialog,  ContentDialogOpenedEventArgs>// This API is not available in Javascript.
<ContentDialog Opened="eventhandler"/>

PrimaryButtonClick PrimaryButtonClick PrimaryButtonClick PrimaryButtonClick

Occurs after the primary button has been tapped.

public : event TypedEventHandler PrimaryButtonClick<ContentDialog,  ContentDialogButtonClickEventArgs>public event TypedEventHandler PrimaryButtonClick<ContentDialog,  ContentDialogButtonClickEventArgs>Public Event PrimaryButtonClick<ContentDialog,  ContentDialogButtonClickEventArgs>// This API is not available in Javascript.
<ContentDialog PrimaryButtonClick="eventhandler"/>

SecondaryButtonClick SecondaryButtonClick SecondaryButtonClick SecondaryButtonClick

Occurs after the secondary button has been tapped.

public : event TypedEventHandler SecondaryButtonClick<ContentDialog,  ContentDialogButtonClickEventArgs>public event TypedEventHandler SecondaryButtonClick<ContentDialog,  ContentDialogButtonClickEventArgs>Public Event SecondaryButtonClick<ContentDialog,  ContentDialogButtonClickEventArgs>// This API is not available in Javascript.
<ContentDialog SecondaryButtonClick="eventhandler"/>

See Also