问题
I'm trying to make a flat button with a red border instead of a black border when the button is pressed.
<Style TargetType="Button" x:Key="FlatButtonStyle">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Margin" Value="2" />
<Setter Property="FontSize" Value="30" />
<Style.Triggers>
<Trigger Property="IsFocused" Value="true">
<Setter Property="BorderBrush" Value="#E01919"/>
</Trigger>
</Style.Triggers>
</Style>
The problem is that there still is a black border, so now its showing both a red and black border.
How do i get rid of the black border ?
Thanks.
回答1:
Stick this in your XAML BorderBrush="#000000"
you can also grab a list of colours here
回答2:
Try this:
<UserControl.Resources>
<Style x:Key="Flat">
<Setter Property="Control.BorderBrush" Value="{x:Null}" />
<Style.Triggers>
<Trigger Property="Control.IsMouseOver" Value="True">
<Setter Property="Control.BorderBrush" Value="{x:Null}" />
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Resources>
<StackPanel>
<Button Style="{StaticResource Flat}">Hello</Button>
</StackPanel>
来源:https://stackoverflow.com/questions/7837816/how-to-change-the-border-color-of-a-flat-button-style