Share via


ContentDialog.CloseButtonText 屬性

定義

取得或設定要顯示在關閉按鈕上的文字。

public:
 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"/>

屬性值

String

Platform::String

winrt::hstring

要顯示在關閉按鈕上的文字。 若要隱藏此按鈕,請將文字設定為 null 或空字串。 預設為空字串。

備註

每個對話方塊都必須包含可讓使用者放心結束對話方塊的安全、非破壞性按鈕。

ContentDialog 有內建的關閉按鈕,您可以藉由將此屬性設定為非空白字串來使用。 當此屬性設定為空字串或 null時,會隱藏關閉按鈕。

內建的關閉按鈕可讓您為所有輸入建立正確的用戶體驗,包括滑鼠、鍵盤、觸控和遊戲控制器。 對話框會在下列情況下關閉:

  • 用戶按下或點選關閉按鈕。
  • 使用者按下系統返回按鈕。
  • 使用者按下鍵盤上的 ESC 按鈕。
  • 用戶按下遊戲控制器 B。

叫用關閉按鈕會 ContentDialogResult.None傳回 ,會引發 CloseButtonClick 事件,您可以選擇處理此事件,並叫用任何已設定的 CloseButtonCommand

適用於

另請參閱