Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Event fired when an animation ends?

 
 
Old 01-31-2006   #1 (permalink)
Jason Dolinger


 
 

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 SpecsSystem Spec
Old 01-31-2006   #2 (permalink)
viliescu


 
 

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 SpecsSystem Spec
Old 01-31-2006   #3 (permalink)
viliescu


 
 

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 SpecsSystem Spec
 

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46