Reputation: 3822
Can someone please explain to me why this doesn't work? The Buttons in the ToolBar are not getting the Black BorderBrush property setting. I've tried TargetType="Button" and TargetType="{x:Type Button}" but neither work. I've done almost exactly the same thing for a series of Labels and it worked fine. I'm pretty new to WPF. Is there something I'm not understanding about style precedence here? Thanks!
...Window Definition...
<Grid>
<Grid.Resources>
<Style TargetType="{x:Type Button}">
<Setter Property="BorderBrush" Value="Black" />
</Style>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<ToolBar Grid.Column="0" Grid.Row="0" Margin="0">
<Button>
<StackPanel Orientation="Horizontal" Height="Auto">
<Rectangle Width="16" Height="16" Fill="LightBlue" VerticalAlignment="Center"></Rectangle>
<Label Padding="0" VerticalAlignment="Center" HorizontalAlignment="Left">Redraw</Label>
</StackPanel>
</Button>
... More Buttons ...
</ToolBar>
</Grid>
... End Window Definition ...
Upvotes: 1
Views: 610
Reputation: 13679
here you go
<Style x:Key="{x:Static ToolBar.ButtonStyleKey}"
TargetType="{x:Type Button}">
<Setter Property="BorderBrush"
Value="Black" />
</Style>
from How to: Style Controls on a ToolBar
The ToolBar defines ResourceKey objects to specify the style of controls within the ToolBar. To style a control in a ToolBar, set the x:key attribute of the style to a ResourceKey defined in ToolBar.
The ToolBar defines the following ResourceKey objects:
Upvotes: 2