![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | 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) |
| | 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![]() |
| | #3 (permalink) |
| | 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 | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Dcom ends with error | Vista performance & maintenance | |||
| Setting up your desktop never ends | Vista installation & setup | |||
| Vista may get me fired | Vista music pictures video | |||
| Re: Roy Gets Fired From His Job For Being Transgendered!! | Vista General | |||