为什么我的WPF动画只开始一次
本文关键字:一次 开始 我的 WPF 动画 为什么 | 更新日期: 2023-09-27 18:03:27
我有一个动画,它第一次被触发时工作良好,但当GoNextCmd
第二次上升为true时,动画不再启动。下面是我的代码:
<ItemsControl DockPanel.Dock="Top" ItemsSource="{Binding ViewCollection}" x:Name="itemsControl">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<ContentControl Content="{Binding}" Width="500" Name="toMove">
</ContentControl>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.Style>
<Style TargetType="ItemsControl">
<Style.Triggers>
<DataTrigger Binding="{Binding GoNextCmd}" Value="true">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ThicknessAnimation RepeatBehavior="1x" FillBehavior="Stop" Storyboard.TargetProperty="Margin" By="-250,0,0,0" Duration="0:0:1">
<ThicknessAnimation.EasingFunction>
<QuinticEase EasingMode="EaseInOut" />
</ThicknessAnimation.EasingFunction>
</ThicknessAnimation>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
</Style.Triggers>
</Style>
</ItemsControl.Style>
</ItemsControl>
有人知道这件事吗?
我不知道你的意思是什么命令上升为真,但与DataTriggers你应该使用属性使用INotifyPropertyChanged(和上升PropertyChanged时使用setter)。