WindowsCompositionSamples icon indicating copy to clipboard operation
WindowsCompositionSamples copied to clipboard

WindowsComposition Animation End Event missing.

Open selastingeorge opened this issue 4 years ago • 1 comments

I have been using Winrt with WPF to create the acrylic effect on wpf. I managed to fix the Aerospace issue by drawing the acrylic into a separate window and overlapping my content window on top of it, both windows are synced to move or resize together, but for the acrylic layer not to flicker i have to create Transparent Window, So i lost the Window Animations, currently i am trying to recreate the window Maximize and Restore animations, I Use the Winrt API for animating the Acrylic Visual Layer, I successfully created the window Maximize animation, but in window restore animation i need a way to know when the animation is finished. I have Raided the entire class and doesn't found an event listener for animation. Here are the Codes,

The Code for maximize animation :

public void animateMaximize()
{
     var sampleAnim= _compositor.CreateVector3KeyFrameAnimation();
     sampleAnim.InsertKeyFrame(0f, new Vector3(0.9f));
     sampleAnim.InsertKeyFrame(1.0f, new Vector3(1.0f));
     sampleAnim.Duration = TimeSpan.FromMilliseconds(350);
     _acrylicVisual.CenterPoint = new Vector3(_acrylicVisual.Size.X / 2, _acrylicVisual.Size.Y / 2, 0.0f);
     _acrylicVisual.StartAnimation("Scale", sampleAnim);
}

The Code for restore animation :

public void animateRestore()
{
     var sampleAnim= _compositor.CreateVector3KeyFrameAnimation();
     sampleAnim.InsertKeyFrame(0f, new Vector3(1.0f));
     sampleAnim.InsertKeyFrame(1.0f, new Vector3(0.9f));
     sampleAnim.Duration = TimeSpan.FromMilliseconds(350);
     _acrylicVisual.CenterPoint = new Vector3(_acrylicVisual.Size.X / 2, _acrylicVisual.Size.Y / 2, 0.0f);
     _acrylicVisual.StartAnimation("Scale", sampleAnim);
}

So I need a method, or a way to find when the sampleAnim finishes. if a reference to any docs on this is available please share it. Or Does Windows.UI.Composition Does not support These Methods.

selastingeorge avatar Apr 03 '21 14:04 selastingeorge

This can be accomplished using CompositionScopedBatch https://docs.microsoft.com/en-us/uwp/api/windows.ui.composition.compositionscopedbatch?view=winrt-19041

JohnnyWestlake avatar Apr 30 '21 09:04 JohnnyWestlake