如何使属性值闪烁?

时间:2018-07-07 16:12:05

标签: c# wpf

我有一个名为ResultChanged的属性,该属性绑定了一个DataGrid项,当值为true时,应用于style的{​​{1}}将使DataGridCell,所以我需要将cell的{​​{1}}闪烁5次,将Cell的值更改为true和false,这是我的xaml设计:

DataGrid

我试图以这种方式实现逻辑:

ResultChanged

问题是<DataGridTextColumn Header="{DynamicResource hour}" Binding="{Binding Result}"> <DataGridTextColumn.CellStyle> <Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}"> <Style.Triggers> <DataTrigger Binding="{Binding ResultChanged}" Value="True"> <Setter Property="Background" Value="Orange" /> <Setter Property="Foreground" Value="Black" /> </DataTrigger> <Style.Triggers> </Style> </DataGridTextColumn.CellStyle> 会一直变色,我看不到任何眨眼的念头吗?

1 个答案:

答案 0 :(得分:1)

您可以为您的<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div class="acc_warap"> <div class="single_acc"> <div class="acc_title" acc-data="no1"> <h4>This is accordion title</h4> </div> <div class="acc_content no1"> <p>Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod.</p> </div> </div><!-- End single accordion--> <div class="single_acc"> <div class="acc_title" acc-data="no2"> <h4>This is accordion title</h4> </div> <div class="acc_content no2"> <p>Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod.</p> </div> </div><!-- End single accordion--> <div class="single_acc"> <div class="acc_title" acc-data="no3"> <h4>This is accordion title</h4> </div> <div class="acc_content no3"> <p>Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod.</p> </div> </div><!-- End single accordion--> <div class="single_acc"> <div class="acc_title" acc-data="no4"> <h4>This is accordion title</h4> </div> <div class="acc_content no4"> <p>Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa nesciunt laborum eiusmod.</p> </div> </div><!-- End single accordion--> </div>尝试这种样式吗?

DataGridCell

以上样式将<DataGridTextColumn Header="{DynamicResource hour}" Binding="{Binding Result}"> <DataGridTextColumn.CellStyle> <Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}"> <Style.Triggers> <DataTrigger Binding="{Binding ResultChanged}" Value="True" > <DataTrigger.EnterActions> <BeginStoryboard> <Storyboard x:Name="Blink" AutoReverse="True" RepeatBehavior="5x"> <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)"> <EasingColorKeyFrame KeyTime="00:00:01" Value="Orange" /> </ColorAnimationUsingKeyFrames> <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(Foreground).(SolidColorBrush.Color)"> <EasingColorKeyFrame KeyTime="00:00:01" Value="Black" /> </ColorAnimationUsingKeyFrames> </Storyboard> </BeginStoryboard> </DataTrigger.EnterActions> </DataTrigger> </Style.Triggers> </Style> </DataGridTextColumn.CellStyle> </DataGridTextColumn> 本身。如果要在动画结束后保留​​橙色,可以将AutoReverse设置为AutoReverse。但这不会在反向上获得相同的 Easing 操作。

如果您希望反向执行 Easing 操作,则可以在初始False 00完成后引入另一个操作(StoryBoard)来执行此操作。 :00:10 。喜欢,

StoryBoard

您可以根据自己的动画偏好在<DataGridTextColumn Header="{DynamicResource hour}" Binding="{Binding Result}"> <DataGridTextColumn.CellStyle> <Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource MaterialDesignDataGridCell}"> <Style.Triggers> <DataTrigger Binding="{Binding ResultChanged}" Value="True" > <DataTrigger.EnterActions> <BeginStoryboard> <Storyboard> <Storyboard x:Name="Blink" AutoReverse="True" RepeatBehavior="5x"> <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)"> <EasingColorKeyFrame KeyTime="00:00:01" Value="Orange" /> </ColorAnimationUsingKeyFrames> <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetProperty="(Foreground).(SolidColorBrush.Color)"> <EasingColorKeyFrame KeyTime="00:00:01" Value="Black" /> </ColorAnimationUsingKeyFrames> </Storyboard> <Storyboard AutoReverse="False"> <ColorAnimationUsingKeyFrames BeginTime="00:00:10" Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)"> <EasingColorKeyFrame KeyTime="00:00:01" Value="Orange" /> </ColorAnimationUsingKeyFrames> </Storyboard> </Storyboard> </BeginStoryboard> </DataTrigger.EnterActions> </DataTrigger> </Style.Triggers> </Style> </DataGridTextColumn.CellStyle> </DataGridTextColumn> AutoReverse周围玩耍。