Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enabling mnemonics in button

I read that in order to enable mnemonics, I have to turn on RecognizesAccessKey on ContentPresenter.
When I tried this code, I saw only text without button.

<Button x:Name="OkButton" Content="_OK" Command="{Binding ExecuteCommand}">
    <Button.Template>
        <ControlTemplate TargetType="Button">
            <ContentPresenter RecognizesAccessKey="True" />
        </ControlTemplate>
    </Button.Template>
</Button>

Probably there's a way to change it without deleting button's default template?

like image 894
Andrey Avatar asked Apr 14 '26 11:04

Andrey


1 Answers

This question provides the answer, altough it's not exactly the same question. Here's how the mnemonic is set and working:

<Button>
    <AccessText>_Button</AccessText>
</Button>

Like in WinForms this is done by adding a _ before the character to be the mnemonic key.

like image 190
Abbas Avatar answered Apr 16 '26 11:04

Abbas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!