C# 在鼠标输入时设置动画后的按钮颜色

C# 在鼠标输入时设置动画后的按钮颜色,c#,wpf,xaml,C#,Wpf,Xaml,我有一个鼠标悬停的动画按钮来改变背景和文本颜色,但我希望在点击后设置它,我的代码不起作用 <Button Style="{StaticResource ButtonProduct}" x:Name="Overview_Button" Click="Overview_Button_Click" FontFamily="pack://application:,,,/Images/Fonts/#HandelGothicEF" Width="198" Height="50" Margin="

我有一个鼠标悬停的动画按钮来改变背景和文本颜色,但我希望在点击后设置它,我的代码不起作用

 <Button Style="{StaticResource ButtonProduct}" x:Name="Overview_Button" Click="Overview_Button_Click" FontFamily="pack://application:,,,/Images/Fonts/#HandelGothicEF" Width="198" Height="50"   Margin="0,30,0,20" FontSize="26">
    <TextBlock FontFamily="Univers LT Std 57 Cn" FontSize="16" Text="Overview" />
</Button>

您可以使用for按钮。您还没有为单击编写代码。您所说的“单击后”是指释放鼠标按钮的时间吗?还是被按住?释放。我可以使用,但我需要删除其他按钮单击时的颜色。我只能通过代码来实现,听起来你真的想要一个单选按钮,然后使用Checked事件来设置你的颜色。当选中(即单击)同一RadioButton组中的另一个按钮时,先前单击的按钮将被取消选中,您可以将其恢复为原始状态。
<!-- ButtonProduct -->
<Style x:Key="ButtonProduct" TargetType="Button">
    <Setter Property="SnapsToDevicePixels" Value="true"/>
    <Setter Property="OverridesDefaultStyle" Value="true"/>
    <Setter Property="HorizontalAlignment" Value="Center"/>
    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="{x:Type Button}">
                <Border Name="Border" CornerRadius="0" BorderThickness="0" Focusable="False" BorderBrush="Transparent" Background="White">
                    <ContentPresenter Margin="2" HorizontalAlignment="Center" VerticalAlignment="Center" RecognizesAccessKey="True"/>
                </Border>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="true">
                        <Setter Property="Foreground" Value="White" />
                    </Trigger>
                    <EventTrigger RoutedEvent="MouseEnter">
                        <BeginStoryboard>
                            <Storyboard>
                                <ColorAnimation From="White" To="#52b0ca" Duration="0:0:0.5" Storyboard.TargetName="Border" Storyboard.TargetProperty="Background.Color"/>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                    <EventTrigger RoutedEvent="MouseLeave">
                        <BeginStoryboard>
                            <Storyboard>
                                <ColorAnimation From="#52b0ca" To="White" Duration="0:0:0.5" Storyboard.TargetName="Border" Storyboard.TargetProperty="Background.Color"/>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>
private void Overview_Button_Click(object sender, RoutedEventArgs e)
        {
            var bc = new BrushConverter();
            Overview_Button.Background = (Brush)bc.ConvertFrom("#51b0ce");

            Clear_Main_Panel();
            overviewObj = new Overview(family, Product_CombBox.SelectedIndex);
            this.Center_Panel.Children.Add(overviewObj);
            isOverview = true;
        }