为什么我点击按钮后左眼不再眨眼

问题描述

我制作了一个按钮,内容为黄色笑脸。当鼠标进入右眼应该眨眼。当布尔属性改变值时,左眼应该眨眼。当我点击这个按钮时,两只眼睛都会眨眼。使用第二个布尔属性,颜色应该从黄色变为红色,微笑的嘴巴应该变成悲伤的嘴巴。鼠标输入眨眼工作正常。此外,布尔属性更改触发器工作正常,直到我单击按钮。当我单击按钮时,两只眼睛都应该眨眼。但是在此之后,布尔属性更改触发器不再起作用!!!!

是什么让我错了? 我已经处理这个问题一天多了。

<Button x:Name="buttonStartStop" Command="StartStop_Command" Grid.Column="1" Width="60" Margin="0,4,0">
                <Button.Resources>
                    <Color x:Key="yellow">#FFFF00</Color>
                    <SolidColorBrush x:Key="yellowSCB" Color="{StaticResource yellow}" />
                    <Color x:Key="red">#FF5050</Color>
                    <SolidColorBrush x:Key="redSCB" Color="{StaticResource red}" />
                    <Color x:Key="black">#202020</Color>
                    <SolidColorBrush x:Key="blackSCB" Color="{StaticResource black}" />
                    <Duration x:Key="dur">0:0:0.2</Duration>
                    <system:Double x:Key="smileySize">100.0</system:Double>
                    <system:Double x:Key="smileyEyeSize">20.0</system:Double>

                    <Storyboard x:Key="winkRight">
                        <DoubleAnimation Duration="{StaticResource dur}" To="34" Storyboard.TargetName="eyeRight" Storyboard.TargetProperty="(Canvas.Top)" />
                        <DoubleAnimation Duration="{StaticResource dur}" To="2" Storyboard.TargetName="eyeRight" Storyboard.TargetProperty="Height" />
                        <DoubleAnimation BeginTime="0:0:0.3" Duration="{StaticResource dur}" To="25" Storyboard.TargetName="eyeRight" Storyboard.TargetProperty="(Canvas.Top)" />
                        <DoubleAnimation BeginTime="0:0:0.3" Duration="{StaticResource dur}" To="{StaticResource smileyEyeSize}" Storyboard.TargetName="eyeRight" Storyboard.TargetProperty="Height" />
                    </Storyboard>

                    <Storyboard x:Key="winkLeftB">
                        <DoubleAnimation Duration="{StaticResource dur}" To="34" Storyboard.TargetName="eyeLeft" Storyboard.TargetProperty="(Canvas.Top)" />
                        <DoubleAnimation Duration="{StaticResource dur}" To="2" Storyboard.TargetName="eyeLeft" Storyboard.TargetProperty="Height" />
                        <DoubleAnimation BeginTime="0:0:0.3" Duration="{StaticResource dur}" To="25" Storyboard.TargetName="eyeLeft" Storyboard.TargetProperty="(Canvas.Top)" />
                        <DoubleAnimation BeginTime="0:0:0.3" Duration="{StaticResource dur}" To="{StaticResource smileyEyeSize}" Storyboard.TargetName="eyeLeft" Storyboard.TargetProperty="Height" />
                    </Storyboard>

                    <Storyboard x:Key="winkLeft">
                        <DoubleAnimation Duration="{StaticResource dur}" To="34" Storyboard.TargetProperty="(Canvas.Top)" />
                        <DoubleAnimation Duration="{StaticResource dur}" To="2" Storyboard.TargetProperty="Height" />
                        <DoubleAnimation BeginTime="0:0:0.3" Duration="{StaticResource dur}" To="25" Storyboard.TargetProperty="(Canvas.Top)" />
                        <DoubleAnimation BeginTime="0:0:0.3" Duration="{StaticResource dur}" To="{StaticResource smileyEyeSize}" Storyboard.TargetProperty="Height" />
                    </Storyboard>

                </Button.Resources>
                <Button.Style>
                    <Style targettype="{x:Type Button}">
                        <Setter Property="Template">
                            <Setter.Value>
                                <ControlTemplate>
                                    <Border x:Name="background" Background="#AAAAAA" BorderBrush="White" BorderThickness="1" CornerRadius="4">
                                        <ViewBox Margin="1">
                                            <Canvas Width="{StaticResource smileySize}" Height="{StaticResource smileySize}">
                                                <Ellipse x:Name="smiley" Width="{StaticResource smileySize}" Height="{StaticResource smileySize}" Fill="{StaticResource yellowSCB}" >
                                                    <Ellipse.Style>
                                                        <Style targettype="{x:Type Ellipse}">
                                                            <Style.Triggers>
                                                                <DataTrigger Binding="{Binding Path=HeadlineValues.Explode}" Value="True">
                                                                    <DataTrigger.Enteractions>
                                                                        <BeginStoryboard>
                                                                            <Storyboard>
                                                                                <ColorAnimation Duration="{StaticResource dur}" To="{StaticResource red}" Storyboard.TargetProperty="(Fill).(Color)" />
                                                                            </Storyboard>
                                                                        </BeginStoryboard>
                                                                    </DataTrigger.Enteractions>
                                                                    <DataTrigger.Exitactions>
                                                                        <BeginStoryboard>
                                                                            <Storyboard>
                                                                                <ColorAnimation Duration="{StaticResource dur}" To="{StaticResource yellow}" Storyboard.TargetProperty="(Fill).(Color)" />
                                                                            </Storyboard>
                                                                        </BeginStoryboard>
                                                                    </DataTrigger.Exitactions>
                                                                </DataTrigger>
                                                            </Style.Triggers>
                                                        </Style>
                                                    </Ellipse.Style>
                                                    <Ellipse.Effect>
                                                        <DropShadowEffect BlurRadius="10" ShadowDepth="0" Color="{Binding Path=Fill.Color,RelativeSource={RelativeSource AncestorType=Ellipse}}" />
                                                    </Ellipse.Effect>
                                                </Ellipse>
                                                <Ellipse x:Name="eyeLeft" Width="{StaticResource smileyEyeSize}" Height="{StaticResource smileyEyeSize}" Fill="{StaticResource blackSCB}" Canvas.Left="20" Canvas.Top="25">
                                                    <Ellipse.Style>
                                                        <Style targettype="{x:Type Ellipse}">
                                                            <Style.Triggers>
                                                                <DataTrigger Binding="{Binding Path=HeadlineValues.FieldClick}" Value="True">
                                                                    <DataTrigger.Enteractions>
                                                                        <BeginStoryboard Storyboard="{StaticResource winkLeft}" />
                                                                    </DataTrigger.Enteractions>
                                                                </DataTrigger>
                                                                <DataTrigger Binding="{Binding Path=HeadlineValues.FieldClick}" Value="True">
                                                                    <DataTrigger.Exitactions>
                                                                        <BeginStoryboard Storyboard="{StaticResource winkLeft}" />
                                                                    </DataTrigger.Exitactions>
                                                                </DataTrigger>
                                                            </Style.Triggers>
                                                        </Style>
                                                    </Ellipse.Style>
                                                </Ellipse>
                                                
                                                <Ellipse x:Name="eyeRight" Width="{StaticResource smileyEyeSize}" Height="{StaticResource smileyEyeSize}" Fill="{StaticResource blackSCB}" Canvas.Left="60" Canvas.Top="25" />
                                                
                                                <Path stroke="{StaticResource blackSCB}" strokeThickness="10" strokeStartLineCap="Round" strokeEndLineCap="Round">
                                                    <Path.Style>
                                                        <Style targettype="{x:Type Path}">
                                                            <Setter Property="Data">
                                                                <Setter.Value>
                                                                    <PathGeometry FillRule="Nonzero">
                                                                        <Pathfigure StartPoint="20,65" IsClosed="False" IsFilled="False">
                                                                            <BezierSegment Point1="20,65" Point2="50,100" Point3="80,65" />
                                                                        </Pathfigure>
                                                                    </PathGeometry>
                                                                </Setter.Value>
                                                            </Setter>
                                                            <Style.Triggers>
                                                                <DataTrigger Binding="{Binding Path=HeadlineValues.Explode}" Value="True">
                                                                    <DataTrigger.Enteractions>
                                                                        <BeginStoryboard>
                                                                            <Storyboard>
                                                                                <PointAnimation Duration="{StaticResource dur}" To="30,75" Storyboard.TargetProperty="Data.(PathGeometry.figures)[0].(Pathfigure.StartPoint)" />
                                                                                <PointAnimation Duration="{StaticResource dur}" To="30,75" Storyboard.TargetProperty="Data.(PathGeometry.figures)[0].(Pathfigure.Segments)[0].(BezierSegment.Point1)" />
                                                                                <PointAnimation Duration="{StaticResource dur}" To="50,55" Storyboard.TargetProperty="Data.(PathGeometry.figures)[0].(Pathfigure.Segments)[0].(BezierSegment.Point2)" />
                                                                                <PointAnimation Duration="{StaticResource dur}" To="70,75" Storyboard.TargetProperty="Data.(PathGeometry.figures)[0].(Pathfigure.Segments)[0].(BezierSegment.Point3)" />
                                                                            </Storyboard>
                                                                        </BeginStoryboard>
                                                                    </DataTrigger.Enteractions>
                                                                    <DataTrigger.Exitactions>
                                                                        <BeginStoryboard>
                                                                            <Storyboard>
                                                                                <PointAnimation Duration="{StaticResource dur}" To="20,65" Storyboard.TargetProperty="Data.(PathGeometry.figures)[0].(Pathfigure.StartPoint)" />
                                                                                <PointAnimation Duration="{StaticResource dur}" To="20,65" Storyboard.TargetProperty="Data.(PathGeometry.figures)[0].(Pathfigure.Segments)[0].(BezierSegment.Point1)" />
                                                                                <PointAnimation Duration="{StaticResource dur}" To="50,100" Storyboard.TargetProperty="Data.(PathGeometry.figures)[0].(Pathfigure.Segments)[0].(BezierSegment.Point2)" />
                                                                                <PointAnimation Duration="{StaticResource dur}" To="80,65" Storyboard.TargetProperty="Data.(PathGeometry.figures)[0].(Pathfigure.Segments)[0].(BezierSegment.Point3)" />
                                                                            </Storyboard>
                                                                        </BeginStoryboard>
                                                                    </DataTrigger.Exitactions>
                                                                </DataTrigger>
                                                            </Style.Triggers>
                                                        </Style>
                                                    </Path.Style>
                                                </Path>
                                            </Canvas>
                                        </ViewBox>
                                    </Border>
                                    <ControlTemplate.Triggers>
                                        <EventTrigger RoutedEvent="MouseEnter">
                                            <BeginStoryboard Storyboard="{StaticResource winkRight}" />
                                            <BeginStoryboard>
                                                <Storyboard>
                                                    <ColorAnimation Duration="{StaticResource dur}" To="#BBBBBB" Storyboard.TargetName="background" Storyboard.TargetProperty="Background.Color" />
                                                </Storyboard>
                                            </BeginStoryboard>
                                        </EventTrigger>
                                        <EventTrigger RoutedEvent="MouseLeave">
                                            <BeginStoryboard>
                                                <Storyboard>
                                                    <ColorAnimation Duration="{StaticResource dur}" To="#AAAAAA" Storyboard.TargetName="background" Storyboard.TargetProperty="Background.Color" />
                                                </Storyboard>
                                            </BeginStoryboard>
                                        </EventTrigger>
                                        <EventTrigger RoutedEvent="Button.Click">
                                            <BeginStoryboard Storyboard="{StaticResource winkRight}" />
                                            <BeginStoryboard Storyboard="{StaticResource winkLeftB}" />
                                        </EventTrigger>
                                    </ControlTemplate.Triggers>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                    </Style>
                </Button.Style>
            </Button>

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)