Search code examples
.netwpfstylesaccess-keys

Access key not working on CheckBox after applying style


Ive applied some styling on CheckBoxes in my app to write default values to some its properties.

 <Style
        TargetType="{x:Type CheckBox}">
        <Setter
            Property="HorizontalAlignment"
            Value="Left" />
        <Setter
            Property="Margin"
            Value="2" />
        <Setter
            Property="MinHeight"
            Value="22" />
 </Style>

But that ruined the access keys, now Content looks like for example: _Is Active and not Is Active with access on ALT hold+I. How to make style work with access keys working too?


Solution

  • Tested it just now, VS'10, WPF 4.0, SP1. worked fine. Alt+I changed checkbox state. code for test:

    <Window.Resources>
        <Style TargetType="{x:Type CheckBox}">
            <Setter
                Property="HorizontalAlignment"
                Value="Left" />
            <Setter
                Property="Margin"
                Value="2" />
            <Setter
                Property="MinHeight"
                Value="22" />
        </Style>
    </Window.Resources>
    <CheckBox Content="_IsActive" />
    

    Maybe you forgot to specify some aspects?

    Or I don't understand something