WPF Animation Completed Event
-
Friday, March 20, 2009 7:32 AMHi All,
I am trying to animate an object vertically, from point A to B , i am using a ThicknessAnimation to achieve this. However i noticed that if i place the duration of the animation to 100 ms, the Completed event is being called before the animation is actually completed. I noticed this by placing a message box in the Completed event handler. Visually i notice that the animation stopped a little before the end when the messagebox appeared. Could i be doing something wrong?
Thanks!
All Replies
-
Sunday, March 22, 2009 1:53 PM
Hi,
Could you please provide a simplified example to demonstrate the issue you are encountering?
Thanks.
Jim Zhou -MSFT -
Sunday, March 22, 2009 4:41 PM
I have used similar thing in my article
please go through it, I have explained I hope this will help you :)
http://www.codeproject.com/KB/WPF/WITIYMIWYG.aspx
Prasad - www.beautifulmind.blog.co.in- Proposed As Answer by prasad22 Sunday, March 22, 2009 4:41 PM
-
Sunday, March 22, 2009 5:26 PMHi All,
Below is a small portion of my code.
xaml:
<Page.Resources>
<Storyboard x:Key="HighLightAnim">
<ThicknessAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="highlight_bar" Storyboard.TargetProperty="(FrameworkElement.Margin)">
<SplineThicknessKeyFrame/>
<SplineThicknessKeyFrame/>
</ThicknessAnimationUsingKeyFrames>
</Storyboard>
</Page.Resources>
C# Code behind:
void OnAnimationCompleted(object sender, EventArgs e)
{
MessageBox.Show("Completed");
}
////////////////////////////////////////////////////////////////////////////////////
private void Animate()
{
Storyboard stb_hightLightAnim = (Storyboard)this.Resources["HighLightAnim"];
stb_hightLightAnim.Completed += new EventHandler(OnAnimationCompleted);
ThicknessAnimationUsingKeyFrames highlightThicknessAnim;
highlightThicknessAnim = (ThicknessAnimationUsingKeyFrames)stb_hightLightAnim.Children[0];
highlightThicknessAnim.KeyFrames[0].Value = new Thickness(0, 0, 0, 0);
highlightThicknessAnim.KeyFrames[1].Value = new Thickness(0, 47, 0, 0);
highlightThicknessAnim.KeyFrames[0].KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(100));
highlightThicknessAnim.KeyFrames[1].KeyTime = KeyTime.FromTimeSpan(TimeSpan.FromMilliseconds(100));
stb_hightLightAnim.Begin(this);
}
The message box is appearing before the animation is complete .
Regards.
-
Thursday, May 28, 2009 1:34 PM
private void Animate() { Storyboard stb_hightLightAnim = (Storyboard)this.Resources["HighLightAnim"]; stb_hightLightAnim.Completed += ((s,e)=>MessageBox.Show("Completed")); // your other codes.try that.
stb_hightLightAnim.Begin(this); } -
Thursday, June 17, 2010 1:48 AMI used the StoryBoard component, which has a Completed event.
-
Tuesday, December 14, 2010 12:11 PM
I ran into this bug as well.
Please, answer paolo if you found solution

