zar
zar

Reputation: 12227

Why is styles not getting applied to ToggleButton?

<Window.Resources>
    <vm:NotesViewModel x:Key="vm"/>
    <Style TargetType="ToggleButton">
        <Setter Property="Height" Value="50"/>
        <Setter Property="Width" Value="50"/>
    </Style>
</Window.Resources>

But the ToggleButton in toolbars size remains unchanged. If set the size right there with defintion, it changes but not through window styles in resources.

What am I missing?

Upvotes: 0

Views: 169

Answers (1)

mm8
mm8

Reputation: 169200

The ToolBar applies its own ToggleButton style which you can override by defining a style with an x:Key of ToolBar.ToggleButtonStyleKey:

<Style TargetType="ToggleButton">
    <Setter Property="Height" Value="50"/>
    <Setter Property="Width" Value="50"/>
</Style>

<Style x:Key="{x:Static ToolBar.ToggleButtonStyleKey}"
       TargetType="ToggleButton" BasedOn="{StaticResource {x:Type ToggleButton}}"/>

Upvotes: 1

Related Questions