Share via


AppBarToggleButton.KeyboardAcceleratorTextOverride Property

Definition

Gets or sets a string that overrides the default key combination string associated with a keyboard accelerator.

Example of a menu showing keyboard accelerators for various menu items
Example of a menu showing keyboard accelerators for various menu items

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

Property Value

String

Platform::String

winrt::hstring

The string to replace the default key combination string. The default is null.

Use a single space for no text.

Windows requirements

Device family
Windows 10, version 1803 (introduced in 10.0.17134.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v6.0)

Remarks

Windows 10, version 1703, introduced keyboard accelerator shortcuts. However, these shortcuts were not displayed with the UI of their corresponding controls.

Starting with Windows 10, version 1803, when KeyboardAccelerators are declared, controls display the corresponding key combinations by default.

The override text is not be presented if the system cannot detect an attached keyboard (you can check this yourself through the KeyboardPresent property).

Version compatibility

The KeyboardAcceleratorTextOverride property is not available prior to Windows 10, version 1803. 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.

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

Applies to

See also