I need to know when Composition
animation like ScalarKeyFrameAnimation
finished. How to do this? I've made a call like following:
public void Start()
{
if (!IsLoaded) return;
//SET TARGET PROPERTY - OPACITY
TargetScalarKeyFrameAnimation.Target = "Opacity";
//SET FROM OPACITY
if (From < 0) this.Opacity = 0;
else if (From > 1) this.Opacity = 1;
else this.Opacity = From;
//SET FINAL VALUE (OPACITY)
if (To < 0) TargetScalarKeyFrameAnimation.InsertKeyFrame(1f, 0);
else if (To > 1) TargetScalarKeyFrameAnimation.InsertKeyFrame(1f, 1);
else TargetScalarKeyFrameAnimation.InsertKeyFrame(1f, (float)To);
//SET DURATION
if (Duration.TotalMilliseconds > 0) TargetScalarKeyFrameAnimation.Duration = Duration;
else TargetScalarKeyFrameAnimation.Duration = TimeSpan.FromSeconds(1);
//SET DELAY
if (Delay.TotalMilliseconds > 0) TargetScalarKeyFrameAnimation.DelayTime = Delay;
else TargetScalarKeyFrameAnimation.DelayTime = TimeSpan.FromMilliseconds(0);
//START
this.StartAnimation(TargetScalarKeyFrameAnimation);
}
But how to get notification animation has been finished? It will helps lot to synchronise UI and other animation. StoryboardAnimation
has an event for this.
How to know when Composition animation 'ScalarKeyFrameAnimation' (or similar) finished
Currently, there is no such event that could detect animation finished for composition Api. For your scenario, you could make a timer ans set Interval
same as animation duration, and call StartAnimation
and timer Start
at same time. Then could detect animation finished in timer Tick
event.