ContentDialog.CloseButtonText Property


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

 property Platform::String ^ CloseButtonText { Platform::String ^ get(); void set(Platform::String ^ value); };
winrt::hstring CloseButtonText();

void CloseButtonText(winrt::hstring value);
public string CloseButtonText { get; set; }
var string = contentDialog.closeButtonText;
contentDialog.closeButtonText = string;
Public Property CloseButtonText As String
<ContentDialog CloseButtonText="string"/>

Property Value


The text to display on the close button.

Windows requirements

Device family
Windows 10 Creators Update (introduced in 10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v4.0)


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">
private void ContentDialog_Loaded(object sender, RoutedEventArgs e)
    if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.ContentDialog", "CloseButtonText"))
        contentDialog1.CloseButtonText = "Cancel";
        contentDialog1.SecondaryButtonText = "Cancel";

Applies to