Starting animation defined in XAML from code
-
Hi, I've posted this on the Microsoft forums as well but have not received any usable answer. I have a storyboard in XAML (in a DataTemplate) that I need to start from code. Now I've given up on that idea and rather went with an event to start it. Note: This is WPF. instead of: I now have: gestureMade is an event I created. Which is defined in code as:
public static readonly RoutedEvent gestureMadeEvent = EventManager.RegisterRoutedEvent("gestureMade", RoutingStrategy.Bubble, typeof(gestureMadeHandler), typeof(TouchActor)); public delegate void gestureMadeHandler( object sender, GestureEventArgs e ); public event gestureMadeHandler gestureMade { add { AddHandler(gestureMadeEvent, value); } remove { RemoveHandler(gestureMadeEvent, value); } }
I know the event gets raised because I have a MessageBox that pops up in the handler. The problem is that it doesn't trigger the animation. Am I missing something? rather have something you don't need, than need something you don't have -
Hi, I've posted this on the Microsoft forums as well but have not received any usable answer. I have a storyboard in XAML (in a DataTemplate) that I need to start from code. Now I've given up on that idea and rather went with an event to start it. Note: This is WPF. instead of: I now have: gestureMade is an event I created. Which is defined in code as:
public static readonly RoutedEvent gestureMadeEvent = EventManager.RegisterRoutedEvent("gestureMade", RoutingStrategy.Bubble, typeof(gestureMadeHandler), typeof(TouchActor)); public delegate void gestureMadeHandler( object sender, GestureEventArgs e ); public event gestureMadeHandler gestureMade { add { AddHandler(gestureMadeEvent, value); } remove { RemoveHandler(gestureMadeEvent, value); } }
I know the event gets raised because I have a MessageBox that pops up in the handler. The problem is that it doesn't trigger the animation. Am I missing something? rather have something you don't need, than need something you don't haveWPF forums on MSDN are close to useless unless you have a week to wait, in my experience. The way to start a storyboard in code is something like this: BeginStoryboard storyboardShow = Resources["showAnimation"] as BeginStoryboard; storyboardShow.Storyboard.Begin(this);
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
WPF forums on MSDN are close to useless unless you have a week to wait, in my experience. The way to start a storyboard in code is something like this: BeginStoryboard storyboardShow = Resources["showAnimation"] as BeginStoryboard; storyboardShow.Storyboard.Begin(this);
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
thanks for the reply. The problem is that the BeginStoryboard is in a Trigger, which is far nested into a DataTemplate so I cannot give it a key. I got to the BeginStoryboard through code by navigating through the template and registering everything that I need. So when I finally call story.Storyboard.Begin(this); I get no errors, the code is run (checked via tracing through it) but the animation doesn't happen. Any reason for this? Wrong containingObject?
rather have something you don't need, than need something you don't have