按钮奇怪的背景结束了?

问题描述 投票:0回答:1

我正在用这个

Button
:

<Button Name="buttonAttiva"
        HorizontalAlignment="Center"
        VerticalAlignment="Top"
        Margin="0,560,0,0">
    <TextBlock Text="Attiva" />

就是这样的风格:

<Style TargetType="{x:Type Button}"
       BasedOn="{StaticResource MahApps.Styles.Button}">
    <Setter Property="Width"
            Value="120" />
    <Setter Property="Height"
            Value="46" />
    <Setter Property="BorderThickness"
            Value="0" />
    <Setter Property="BorderBrush"
            Value="Transparent" />
    <Setter Property="Background"
            Value="#81b3d4" />
    <Setter Property="Foreground"
            Value="#ffffff" />
    <Setter Property="FontWeight"
            Value="Bold" />
    <Setter Property="FontSize"
            Value="18" />
    <Setter Property="FontWeight"
            Value="Bold" />
    <Setter Property="FocusVisualStyle"
            Value="{x:Null}" />
    <Setter Property="controls:ControlsHelper.MouseOverBorderBrush"
            Value="Black" />
    <Style.Triggers>
        <Trigger Property="IsMouseOver"
                 Value="True">
            <Setter Property="Background"
                    Value="Orange" />
            <Setter Property="BorderThickness"
                    Value="2" />
            <Setter Property="BorderBrush"
                    Value="Black" />
        </Trigger>
        <Trigger Property="IsPressed"
                 Value="True">
            <Setter Property="Background"
                    Value="Orange" />
            <Setter Property="BorderThickness"
                    Value="2" />
            <Setter Property="BorderBrush"
                    Value="Black" />
        </Trigger>
    </Style.Triggers>
</Style>

正确显示为:

但是,当我用鼠标悬停时,会出现奇怪的“灰色”背景:

如何设置正确的橙色背景?

注意,我正在使用 MahApps.Metro,这可能会覆盖我猜的一些属性?

.net wpf mahapps.metro
1个回答
0
投票

覆盖模板中使用的

MahApps.Brushes.Gray8
资源:

<Style TargetType="{x:Type Button}" BasedOn="{StaticResource MahApps.Styles.Button}">
    <Style.Resources>
        <SolidColorBrush x:Key="MahApps.Brushes.Gray8" Color="Orange" />
    </Style.Resources>
...
© www.soinside.com 2019 - 2024. All rights reserved.