WPF Storyboard GetCurrentState

statestoryboardwpf

I am trying to detect when a storyboard is still active, still has an effect on a property(ie completed by still has a hold on the dependecy property it is animating).

Completed="DeviceExplorer_Completed">

Duration="0:0:0.5">

In code I do
Storyboard aStoryBoard = this.Resources["openDeviceExplorer"] as Storyboard;
aStoryBoard.Begin();

But how do I find out if the animation is still active, or still has an effect on the property value?

I tried
ClockState aClockState = ClockState.Stopped;
aClockState = aStoryBoard.GetCurrentState();

and keep getting the InvalidOperationException "Cannot perform action because the specified Storybopard was not applied to this object ofr interactive control"

I tried a number of permutations like
aStoryBoard.Begin(this, true);
aStoryBoard.Begin(aPanelExternalAvailableCamerasControl, true);

and still keep getting this error

Best Answer

Make sure the Storyboard is controllable. From MSDN: "To make a storyboard controllable in code, you must use the appropriate overload of the storyboard's Begin method and specify true to make it controllable."

More info: http://msdn.microsoft.com/en-us/library/cc672521.aspx

Related Topic