Reputation: 45105
I have written a control that makes a star formation, the number of points and the length of each point is configurable via dependency properties. I can bind them to Slider controls and it all works.
Now I've written a behaviour that 'injects' this star control into the visual tree of a loaded control and then, in code, makes an animation to make the star grow and disappear like a cartoon flash going off.
My animation doesn't run. The Storyboard.Completed
event fires, but a breakpoint in the change handler for the dependency property being animated is never hit after its initial setting when the page loads.
I'm using a couple of DoubleAnimation
instances.
(this is Q/A I solved it after 3 hours)
Upvotes: 1
Views: 78
Reputation: 45105
You need to set the EnableDependentAnimation
property on your DoubleAnimation
s. From MSDN:
Not all custom animations you create can run by default in a Windows Runtime app, if the animation system determines that the animation might cause bad performance in your UI. Animations where the system determines there could be a performance impact are called dependent animations. It's dependent because the clocking of your animation is directly working against the UI thread, which is also where active user input and other updates are trying to apply the runtime changes to UI. A dependent animation that's consuming extensive system resources on the UI thread can make the app appear unresponsive in certain situations. If your animation causes a layout change or otherwise has the potential to impact performance on the UI thread, you often need to explicitly enable the animation to see it run. That's what the EnableDependentAnimation property on specific animation classes is for. See Dependent and independent animations for more info.
Very discoverable. Lucky you chose to RTFM on this day, else you could have ended up writing your own timers and stuff to force all the rest of the work on the clever star control not to have been wasted.
Upvotes: 1