Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controlling WPF Animations in Xaml

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:-

enter image description here

The Storyboards are as follows:

enter image description here

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

like image 503
user630190 Avatar asked Apr 05 '12 10:04

user630190


1 Answers

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>
like image 137
CodeNaked Avatar answered Sep 30 '22 10:09

CodeNaked