Anybody familiar with WPF's storyboard knows that animating with the various UI elements is not a problem at all, but what happens when you want the storyboard to call some code behind? The most important thing to remember about the storyboard is that it can only affect dependency properties. So how do we use this to help us call some code behind? We first need to create our own custom dependency property in the form where the storyboard exists.
Define the static DP.
Implement a non-static wrapper property that will be called by the storyboard.
Now create a storyboard in your resources.
The DoubleAnimationUsingKeyFrames is a collection of key frames where we can store a specific double value with a event time. In our case we can just store the event time as the double value. We will use the Hashtable to store our ICommand with a particular event time as a key. Now we need to add our new frames collection to our storyboard.
With all of that we need to initialize our dependency property.
Notice that we are using our hashtable to store a List<ICommand> for each key time. That way we can load up any particular key time with any number of ICommands. In the the property changed event handler, we just take the double value (which is our key time) and use it to look up our list of ICommands in our hash table. The last step is to iterate through the list of ICommands found at that key time and execute each one.
Remember Me
a@href@title, i, strike, u
Copyright © 2003-2008 Falafel Software Inc.
Subscribe to Falafel Blogs
The opinions expressed herein are Falafel's employees own personal opinions and do not represent Falafel Software's view in any way in case they go bananas!