ContentDialog.CloseButtonText ContentDialog.CloseButtonText ContentDialog.CloseButtonText ContentDialog.CloseButtonText Property

Definition

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

public : Platform::String CloseButtonText { get; set; }
winrt::hstring CloseButtonText();

void CloseButtonText(winrt::hstring closebuttontext);
public string CloseButtonText { get; set; }
Public ReadWrite Property CloseButtonText As string
<ContentDialog CloseButtonText="string"/>

Property Value

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";
    }
}