Reputation: 81
I have a WPF UserControl in which I've defined FlowDirection="RightToLeft"
I've noticed that the direction of all button images in the toolbar has changed because of that.
How can I avoid that without setting FlowDirection="LeftToRight"
for each button ?
Upvotes: 0
Views: 765
Reputation: 81243
You can declare default Style in your resource for button
so that it gets applied to all button by default in your UserControl. This way you don't have to go each button and set its property manually.
<UserControl.Resources>
<Style TargetType="Button">
<Setter Property="FlowDirection" Value="LeftToRight"/>
</Style>
</UserControl.Resources>
It won't work for button since buttons in toolbar apply style identified by ToolBar.ButtonStyleKey
. So add you need to have two styles and simply set second style to be based on first button. This is how you will do that:
<UserControl.Resources>
<Style TargetType="Button">
<Setter Property="FlowDirection" Value="LeftToRight"/>
</Style>
<Style x:Key="{x:Static ToolBar.ButtonStyleKey}" TargetType="Button"
BasedOn="{StaticResource {x:Type Button}}"/>
</UserControl.Resources>
Upvotes: 1