Hi is it possible to assign a ToggleButtonStyle in a Setter in the ExpanderStyle?
Like this is possible in the Calendar:
<Style x:Key="CS" TargetType="{x:Type Calendar}" >
<Setter Property="CalendarDayButtonStyle" Value="{StaticResource CalendarDayButtonStyle}"/>
<Setter Property="CalendarButtonStyle" Value="{StaticResource CalendarButtonStyle}"/>
<Setter Property="CalendarItemStyle" Value="{StaticResource CalendarItemStyle}"/>
</Style>
Background of the question: In BasedOn-Styles i only change the setter and not the whole template for small changes.
Thanks a lot.
This is not possible out-of-the-box. Probably because there isn’t one
ToggleButtonStyle, there is four, one for eachExpandDirectionProbably overkill for you but if you really need this functionality to be reusable you could create your own custom control where you add four Dependency Properties,
ToggleButtonDownStyle,ToggleButtonUpStyle,ToggleButtonLeftStyleandToggleButtonRightStyleand copy the default style forExpanderinto the default Style for your custom control but change the StaticResource forToggleButtonStyle to aTemplateBindingSo it doesn’t come easy but this would allow you to do what you’re after (and I’m guessing you’re mostly interested in the default
Downdirection)Here is how to control could look, I named it
StyleableExpanderand put it in a “WPF Custom Control Library” for reusability. Only addedToggleButtonDownStylefor demo purposeAnd here is (the very verbose)
Generic.xamlwith the default style. StaticResource for theToggleButtonhas been changed to{TemplateBinding ExpanderDownHeaderStyle}. To get all four directions you would need to change the triggers forExpandDirectionas well