-
Apr 2nd, 2010, 12:26 PM
#1
Thread Starter
Lively Member
How to: Execute code when an animation is completed?
Hi my dear guys, i have 2 animations (zoom in and zoom out). How can i execute code only when an animation is completed?
For example:
Code:
Dim anim_SlideOut As Animation.Storyboard = Me.FindResource("SlideOut")
Dim anim_SlideIn As Animation.Storyboard = Me.FindResource("SlideIn")
anim_SlideOut.Begin() <--- start slide out animation (about 1200 ms duration)
'Now, how can i excecute this code when anim_SlideOut animation is completed?
With imgMusicCover
.Source = imgMiniCover1.Source
.Visibility = Windows.Visibility.Visible
End With
....more code here..... hide few controls and show others
anim_SlideIn.Begin() <--- when all is finished, i want to show a slide in animation.
I'm using VB, but i can transform from C#, please help me
-
Apr 2nd, 2010, 01:57 PM
#2
Hyperactive Member
Re: How to: Execute code when an animation is completed?
The workaround solution I've implemented for this type of scenario is using the Completed event from any storyboard.
Hope it helps.
-
Apr 2nd, 2010, 01:59 PM
#3
Thread Starter
Lively Member
Re: How to: Execute code when an animation is completed?
Originally Posted by Pac_741
The workaround solution I've implemented for this type of scenario is using the Completed event from any storyboard.
Hope it helps.
Thanks , For example:
<DoubleAnimation To="35" Storyboard.TargetName="windowHeading"
Storyboard.TargetProperty="FontSize" Duration="0:0:5"
Completed="FinishedAnimation" FillBehavior="Stop" />
can i change the Completed="FinishedAnimation" at runtime?
Last edited by Nikole; Apr 2nd, 2010 at 02:08 PM.
-
Apr 3rd, 2010, 08:25 PM
#4
Thread Starter
Lively Member
Re: How to: Execute code when an animation is completed?
-
Apr 3rd, 2010, 09:23 PM
#5
Hyperactive Member
Re: How to: Execute code when an animation is completed?
What do you want to change it for ? Perhaps what you want to do has another solution.
-
Apr 3rd, 2010, 09:58 PM
#6
Thread Starter
Lively Member
Re: How to: Execute code when an animation is completed?
Originally Posted by Pac_741
What do you want to change it for ? Perhaps what you want to do has another solution.
I can't compile the project with "Completed" property in XAML storyboard. I get a syntax error. "anim_SlideOut.Completed .... function does not exist"
I'm using VS2010 with .NET framework 4.0
-
Apr 3rd, 2010, 10:00 PM
#7
Hyperactive Member
Re: How to: Execute code when an animation is completed?
Where is your storyboard allocated in ? Within the same window.xaml file ? or in a resource dictionary ?
-
Apr 3rd, 2010, 10:03 PM
#8
Thread Starter
Lively Member
Re: How to: Execute code when an animation is completed?
Originally Posted by Pac_741
Where is your storyboard allocated in ? Within the same window.xaml file ? or in a resource dictionary ?
In same window. I've tried to add Completed="GoMyFunction" to xaml storyboard in "Expression Blend", and i get same error, "Project cannot be compiled, unknow Completed property"
-
Apr 3rd, 2010, 10:12 PM
#9
Hyperactive Member
Re: How to: Execute code when an animation is completed?
Could you show me your xaml code ? also, Have you defined GoMyFunction void in the code behind(in the .cs file)
If not add this to your .cs file :
csharp Code:
private void GoMyFunction (object sender, EventArgs e)
{
//Your Code Here
}
-
Apr 3rd, 2010, 10:27 PM
#10
Thread Starter
Lively Member
Re: How to: Execute code when an animation is completed?
Originally Posted by Pac_741
Could you show me your xaml code ? also, Have you defined GoMyFunction void in the code behind(in the .cs file)
If not add this to your .cs file :
csharp Code:
private void GoMyFunction (object sender, EventArgs e)
{
//Your Code Here
}
Yes the event is now defined. and works, thanks!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|