4
我想在動畫完成時收到通知。 但是,當我應用以下代碼時,出現以下錯誤WPF - ColorAnimation完成事件
「事件'已完成'無法在樣式中的目標標記上指定,請使用EventSetter。
<Style x:Key="CredentialEntryListViewItemStyle" TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource alternatingListViewItem}">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
<Style.Triggers>
<DataTrigger Binding="{Binding IsDuplicated}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation AutoReverse="True"
RepeatBehavior="2x"
Completed="OnColorAnimationCompleted"
Storyboard.TargetProperty="Foreground.(SolidColorBrush.Color)"
To="Orange" Duration="0:0:0.3"/>
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
</DataTrigger>
</Style.Triggers>
</Style>
謝謝! 我遇到的真正問題是,一旦動畫完成,我想要將控件的顏色強制爲原始顏色。原因是,如果動畫在短時間內多次啓動,顏色將不會恢復爲原始顏色。解決我的問題是FillBehavior停止。 「通過將FillBehavior設置爲」停止「,您可以告訴動畫在其達到活動期限結束後停止影響其目標屬性。」 感謝您的回答,它幫助我更瞭解WPF。 乾杯! – Terenced 2009-10-02 14:21:07