How to change the border color of a flat button style

若如初见. 提交于 2020-05-29 11:50:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!