在WPF中更改按钮的背景C#

时间:2015-12-04 21:47:46

标签: c# wpf xaml

我试图在鼠标悬停按钮时更改按钮的背景颜色,但是,它似乎不起作用。

我的风格:

  <Window.Resources>
    <Style TargetType="Button" x:Key = "GAButtonDark">
        <Setter Property="Background" Value="#1E1F1F"/>
        <Setter Property="Foreground" Value="#9E9F9F"/>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="Black"/>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Foreground" Value="#70E1E5"/>
            </Trigger>
        </Style.Triggers>
    </Style>
</Window.Resources>

我的按钮

<Button Style ="{StaticResource GAButtonDark}"  Content="Button" HorizontalAlignment="Left" VerticalAlignment="Top" Width="95" Margin="125,45,0,0" Height="35"/>

0 个答案:

没有答案