Share via


AppBarToggleButton.KeyboardAcceleratorTextOverride 屬性

定義

取得或設定字串,這個字串會覆寫與 鍵盤快捷鍵相關聯的預設按鍵組合字串。

顯示各種功能表項鍵盤快捷鍵的功能表範例
顯示各種功能表項鍵盤快捷鍵的功能表範例

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

void KeyboardAcceleratorTextOverride(winrt::hstring value);
public string KeyboardAcceleratorTextOverride { get; set; }
var string = appBarToggleButton.keyboardAcceleratorTextOverride;
appBarToggleButton.keyboardAcceleratorTextOverride = string;
Public Property KeyboardAcceleratorTextOverride As String

屬性值

String

Platform::String

winrt::hstring

要取代預設按鍵組合字串的字串。 預設值是 null。

針對沒有文字使用單一空格。

備註

Windows 10 1703 版引進了鍵盤快捷方式。 不過,這些快捷方式未顯示其對應控件的UI。

從宣告keyboardAccelerators Windows 10 1803版開始,控件預設會顯示對應的按鍵組合。

若系統無法偵測到已連結的鍵盤 (您可以透過 KeyboardPresent 屬性檢查),便不會顯示覆寫文字。

版本相容性

在 Windows 10 1803 版之前,無法使用 KeyboardAcceleratorTextOverride 屬性。 如果您的應用程式在 Microsoft Visual Studio 中的「最低平臺版本」設定小於此頁面稍後需求區塊中顯示的「引進版本」,您必須設計和測試您的應用程式以考慮此專案。 如需詳細資訊,請參閱 版本調適型程序代碼

若要避免在舊版 Windows 10 上執行應用程式時發生例外狀況,請勿在 XAML 中設定此屬性,或在不執行運行時間檢查的情況下使用它。 此範例示範如何使用 ApiInformation 類別來檢查此屬性是否存在,再加以設定。

<CommandBar x:Name="commandBar1" Loaded="CommandBar_Loaded">
    <AppBarToggleButton x:Name="appBarButtonShuffle" Icon="Shuffle" Label="Shuffle"/>
</CommandBar>
private void CommandBar_Loaded(object sender, RoutedEventArgs e)
{
    if (ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.AppBarToggleButton", "KeyboardAcceleratorTextOverride"))
    {
        appBarButtonCut.KeyboardAcceleratorTextOverride = "Ctrl+S";
    }
}

適用於

另請參閱