![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Event fired when an animation ends? Hi all, Is there any event that gets fired when an animation ends that we can take advantage of? I have a simple animation that I'm creating in C# code (I'm not doing it in XAML as it must be applied to any number of elements in a collection at the click of a button, and I don't know how one can do that in XAML). It is meant to animate a property called ScaleFactor that I've declared as a DP on a window, and it looks something like this (assume that w is the window on which I want to animate the ScaleFactor DP): DoubleAnimation scaleAnimationParams = new DoubleAnimation(); scaleAnimationParams.From = 1; scaleAnimationParams.To = .25; scaleAnimationParams.Duration = new Duration(new TimeSpan(0, 0, 0, 0, 500)); w.BeginAnimation(ManagedWindow.ScaleFactorProperty,scaleAnimationParams); Now, is there a way to get notified when the animation is finished? The only events that are available through the animation classes are: - Changed - CurrentGlobalSpeedInvalidated - CurrentGlobalStateInvalidated - CurrentTimeInvalidated Thanks! Jason |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Event fired when an animation ends? Jason Dolinger wrote: > Hi all, > > Is there any event that gets fired when an animation ends that we can > take advantage of? I have a simple animation that I'm creating in C# > code (I'm not doing it in XAML as it must be applied to any number of > elements in a collection at the click of a button, and I don't know how > one can do that in XAML). > > It is meant to animate a property called ScaleFactor that I've declared > as a DP on a window, and it looks something like this (assume that w is > the window on which I want to animate the ScaleFactor DP): > > > > DoubleAnimation scaleAnimationParams = new DoubleAnimation(); > > scaleAnimationParams.From = 1; > scaleAnimationParams.To = .25; > scaleAnimationParams.Duration = new Duration(new TimeSpan(0, 0, 0, > 0, 500)); > w.BeginAnimation(ManagedWindow.ScaleFactorProperty,scaleAnimationParams); > > > Now, is there a way to get notified when the animation is finished? The > only events that are available through the animation classes are: > > - Changed > - CurrentGlobalSpeedInvalidated > - CurrentGlobalStateInvalidated > - CurrentTimeInvalidated > > Thanks! > Jason Taking this even further, it would be nice to have events fired when an animation starts as well (given that you can specify a start time for an animation which is not exactly now...) Thanks, Jason |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Event fired when an animation ends? scaleAnimationParams.CurrentStateInvalidated += delegate(object sender, EventArgs e) { Clock clock = (Clock)sender; if (clock.CurrentState == ClockState.Stopped) { // the animation has ended .... } }; -- Valentin Iliescu [MVP C#] "Jason Dolinger" wrote: > Jason Dolinger wrote: > > Hi all, > > > > Is there any event that gets fired when an animation ends that we can > > take advantage of? I have a simple animation that I'm creating in C# > > code (I'm not doing it in XAML as it must be applied to any number of > > elements in a collection at the click of a button, and I don't know how > > one can do that in XAML). > > > > It is meant to animate a property called ScaleFactor that I've declared > > as a DP on a window, and it looks something like this (assume that w is > > the window on which I want to animate the ScaleFactor DP): > > > > > > > > DoubleAnimation scaleAnimationParams = new DoubleAnimation(); > > > > scaleAnimationParams.From = 1; > > scaleAnimationParams.To = .25; > > scaleAnimationParams.Duration = new Duration(new TimeSpan(0, 0, 0, > > 0, 500)); > > w.BeginAnimation(ManagedWindow.ScaleFactorProperty,scaleAnimationParams); > > > > > > Now, is there a way to get notified when the animation is finished? The > > only events that are available through the animation classes are: > > > > - Changed > > - CurrentGlobalSpeedInvalidated > > - CurrentGlobalStateInvalidated > > - CurrentTimeInvalidated > > > > Thanks! > > Jason > > Taking this even further, it would be nice to have events fired when an > animation starts as well (given that you can specify a start time for an > animation which is not exactly now...) > > Thanks, > Jason > |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: Event fired when an animation ends? if (clock.CurrentState == ClockState.Stopped) should be if (clock.CurrentState != ClockState.Active) -- Valentin Iliescu [MVP C#] "Jason Dolinger" wrote: > Jason Dolinger wrote: > > Hi all, > > > > Is there any event that gets fired when an animation ends that we can > > take advantage of? I have a simple animation that I'm creating in C# > > code (I'm not doing it in XAML as it must be applied to any number of > > elements in a collection at the click of a button, and I don't know how > > one can do that in XAML). > > > > It is meant to animate a property called ScaleFactor that I've declared > > as a DP on a window, and it looks something like this (assume that w is > > the window on which I want to animate the ScaleFactor DP): > > > > > > > > DoubleAnimation scaleAnimationParams = new DoubleAnimation(); > > > > scaleAnimationParams.From = 1; > > scaleAnimationParams.To = .25; > > scaleAnimationParams.Duration = new Duration(new TimeSpan(0, 0, 0, > > 0, 500)); > > w.BeginAnimation(ManagedWindow.ScaleFactorProperty,scaleAnimationParams); > > > > > > Now, is there a way to get notified when the animation is finished? The > > only events that are available through the animation classes are: > > > > - Changed > > - CurrentGlobalSpeedInvalidated > > - CurrentGlobalStateInvalidated > > - CurrentTimeInvalidated > > > > Thanks! > > Jason > > Taking this even further, it would be nice to have events fired when an > animation starts as well (given that you can specify a start time for an > animation which is not exactly now...) > > Thanks, > Jason > |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Vista on HP ends up inqueue. | Judy LaRock | Vista print fax & scan | 1 | 10-14-2007 08:08 PM |
| Vista may get me fired | Keith | Vista music pictures video | 4 | 04-30-2007 09:50 AM |
| Re: Roy Gets Fired From His Job For Being Transgendered!! | spike1@freenet.co.uk | Vista General | 0 | 03-03-2007 02:18 AM |
| Installation ends after 1st reboot | Paul Barkholz | Vista installation & setup | 0 | 02-20-2007 03:26 PM |
| Associating an Animation::Completed event with an object | John Dunn | Avalon | 8 | 12-08-2006 12:45 PM |