Controlling WPF Animations in Xaml

animation, storyboard, wpf

Solution

You may try something like this instead:

<DataTrigger Binding="{Binding Path=RowData.Row.BidUp}" Value="True">
    <DataTrigger.EnterActions>
        <BeginStoryboard Storyboard="{StaticResource AnimateCellBlue}" />
    </DataTrigger.EnterActions>
    <DataTrigger.ExitActions>
        <BeginStoryboard Storyboard="{StaticResource AnimateCellRed}" />
    </DataTrigger.ExitActions>
</DataTrigger>

Problem

I have 2 animations defined to flash cell values in my grid, one when the value increases and one when the value decreases. When running the application in debug I see a huge amount of warnings in the output window along the lines of:- Unable to perform action because the specified Storyboard was never applied to this object for interactive control.; Action='Stop'; Storyboard='System.Windows.Media.Animation.Storyboard'; My animation is fired via a data trigger as follows:- The Storyboards are as follows: Given that it seems like the StopStoryboard is the problem, i.e. there is no storyboard running that needs stopping. Also my understanding is that starting a new animation in WPF will replace any existing animations already running. However if I remove the StopStoryboard from both DataTriggers I get another problem. This time only the BidDownStory will fire. I will never see the cells Animate Blue. Another interesting thing is happening sometimes. If the animation is happening off screen (i.e. the column is not visible) and I scroll so that the column is visible I see the animation as expected. However if I then scroll the grid back to the column is off screen again the animation continues to run but against a different column in the grid! If you can provide any help with fixing these issues It would be much appreciated. Thanks

Original source