Ejemplo n.º 1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            // We don't check for null here because we only visit this page if the MainPage
            // brought us here. Get the visual from the window content and pull it back to
            // our current page.
            var visual =
                ElementCompositionPreview.GetElementChildVisual(
                    Window.Current.Content);

            ElementCompositionPreview.SetElementChildVisual(
                Window.Current.Content,
                null);
            ElementCompositionPreview.SetElementChildVisual(this, visual);

            // Get the Compositor object.
            var compositor = visual.Compositor;
            // Animate our visual to a different spot on the page.
            var animation = compositor.CreateVector3KeyFrameAnimation();

            animation.InsertKeyFrame(0.0f, visual.Offset);
            animation.InsertKeyFrame(
                1.0f,
                new Vector3(
                    (float)Frame.ActualWidth - 150,
                    visual.Offset.Y,
                    visual.Offset.Z));
            animation.Duration = TimeSpan.FromMilliseconds(1500);

            visual.StartAnimation(nameof(Visual.Offset), animation);
        }
Ejemplo n.º 2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            // Attempt to get our visual from our window content.
            var visual =
                ElementCompositionPreview.GetElementChildVisual(Window.Current.Content);

            // OnNavigatedTo will be called every time we navigate to MainPage,
            // including the first time. Because of this, we aren't guaranteed to get
            // a visual back from the call above. Make sure it's not null first.
            if (visual != null)
            {
                // Remove our visual from the window content and re-parent it to our
                // page.
                ElementCompositionPreview.SetElementChildVisual(Window.Current.Content, null);
                ElementCompositionPreview.SetElementChildVisual(this, visual);

                // Create an animation to animate the visual back to where it should
                // be on this page.
                var compositor = visual.Compositor;
                var animation  = compositor.CreateVector3KeyFrameAnimation();
                animation.InsertKeyFrame(0.0f, visual.Offset);
                animation.InsertKeyFrame(1.0f, new Vector3(50.0f, 50.0f, 0.0f));
                animation.Duration = TimeSpan.FromMilliseconds(1500);

                // Start the animation.
                visual.StartAnimation(nameof(Visual.Offset), animation);
            }
        }
Ejemplo n.º 3
0
        private void StatsPage_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            if (this.ActualWidth < 720)
            {
                barMargin = 2;
            }
            else
            {
                barMargin = 5;
            }

            _pageWidth = this.ActualWidth - 96 - (barMargin * 31);

            foreach (var item in Graph.Items)
            {
                var itemContainer = (ListViewItem)Graph.ContainerFromItem(item);

                if (itemContainer == null)
                {
                    return;
                }

                itemContainer.MinWidth = (_pageWidth / 31) + barMargin;

                var bar = itemContainer.ContentTemplateRoot as FrameworkElement;
                bar.Width = (_pageWidth / 31);

                var sprite = ElementCompositionPreview.GetElementChildVisual(VisualTreeHelper.GetChild(bar, 0) as UIElement);
                sprite.Size = new System.Numerics.Vector2((float)bar.Width, sprite.Size.Y);
            }
        }
        private void DetailPanel_OnUnloaded(object sender, RoutedEventArgs e)
        {
            var sprite = ElementCompositionPreview.GetElementChildVisual(Backdrop);

            sprite?.Dispose();
            ElementCompositionPreview.SetElementChildVisual(Backdrop, null);
        }
Ejemplo n.º 5
0
        public void DiscreteVUBar_CorrectAmountOfBarElementVisuals()
        {
            var elementVisual    = (ContainerVisual)ElementCompositionPreview.GetElementChildVisual(sut);
            var elementContainer = (ContainerVisual)elementVisual.Children.Last();

            Assert.AreEqual(sut.Levels.Count(), elementContainer.Children.Count);
        }
Ejemplo n.º 6
0
        private void InitShadow()
        {
            if (SelectedPie != null && PieShadowHost != null)
            {
                var compositor = ElementCompositionPreview.GetElementVisual(this).Compositor;
                SizeBind = compositor.CreateExpressionAnimation("host.Size");
                SizeBind.SetReferenceParameter("host", ElementCompositionPreview.GetElementVisual(PieShadowHost));
                ShadowVisual = compositor.CreateSpriteVisual();
                ShadowVisual.StartAnimation("Size", SizeBind);

                Shadow            = compositor.CreateDropShadow();
                Shadow.Color      = Colors.Black;
                Shadow.Opacity    = 0.8f;
                Shadow.BlurRadius = 6f;
                Shadow.Mask       = SelectedPie.GetAlphaMask();

                ShadowVisual.Shadow = Shadow;

                if (IsShadowEnable)
                {
                    if (ElementCompositionPreview.GetElementChildVisual(PieShadowHost) == null)
                    {
                        ElementCompositionPreview.SetElementChildVisual(PieShadowHost, ShadowVisual);
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public void DiscreteVUBar_ElementVisualChildrenAreOfRightType()
        {
            Type[] expectedTypes = new Type[] { typeof(SpriteVisual), typeof(ContainerVisual) };
            var    elementVisual = (ContainerVisual)ElementCompositionPreview.GetElementChildVisual(sut);

            CollectionAssert.AreEqual(expectedTypes, elementVisual.Children.Select(visual => visual.GetType()).ToArray());
        }
Ejemplo n.º 8
0
 private static void OnIsCoreSocialistValuesEnablePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     if (e.NewValue != e.OldValue)
     {
         if (d is UIElement ele)
         {
             var isEnable = (bool)e.NewValue;
             if (isEnable)
             {
                 ele.AddHandler(UIElement.TappedEvent, ele_TappedEventHandler, true);
             }
             else
             {
                 ele.RemoveHandler(UIElement.TappedEvent, ele_TappedEventHandler);
                 var cVisual = ElementCompositionPreview.GetElementChildVisual(ele) as ContainerVisual;
                 if (cVisual != null)
                 {
                     cVisual.Children.RemoveAll();
                     ElementCompositionPreview.SetElementChildVisual(ele, null);
                     cVisual.Dispose();
                 }
             }
         }
     }
 }
Ejemplo n.º 9
0
        private void ApplyInternal(
            float blurAmount)
        {
            // SOURCE: https://msdn.microsoft.com/en-us/windows/uwp/graphics/using-the-visual-layer-with-xaml

            // Get the host visual and compositor
            Visual     hostVisual = ElementCompositionPreview.GetElementVisual(this._foregroundElement);
            Compositor compositor = hostVisual.Compositor;

            // Create a blur effect
            this._blurEffect = new GaussianBlurEffect
            {
                BlurAmount = blurAmount,
                BorderMode = EffectBorderMode.Hard,
                //Source = new CompositionEffectSourceParameter("backdropBrush"),
                Source = new ArithmeticCompositeEffect
                {
                    MultiplyAmount = 0,
                    Source1Amount  = 0.5f,
                    Source2Amount  = 0.5f,
                    Source1        = new CompositionEffectSourceParameter("backdropBrush"),
                    Source2        = new ColorSourceEffect
                    {
                        Color = global::Windows.UI.Color.FromArgb(255, 0xee, 0xee, 0xee),
                    }
                }
            };

            //  Create an instance of the effect
            using (var effectFactory = compositor.CreateEffectFactory(this._blurEffect))
            {
                this._effectBrush = effectFactory.CreateBrush();
            }

            // Set the effect source to a CompositionBackdropBrush
            this._backdropBrush = compositor.CreateBackdropBrush();
            this._effectBrush.SetSourceParameter("backdropBrush", this._backdropBrush);

            // Get any existing child sprite visual
            this._blurVisual = (SpriteVisual)ElementCompositionPreview.GetElementChildVisual(this._foregroundElement);
            if (null == this._blurVisual)
            {
                // Create a sprite visual to contain the effect
                this._blurVisual       = compositor.CreateSpriteVisual();
                this._blurVisual.Brush = this._effectBrush;

                // Add the sprite visual as a child of the host visual in the visual tree
                ElementCompositionPreview.SetElementChildVisual(this._foregroundElement, this._blurVisual);
            }
            else
            {
                this._blurVisual.Brush = this._effectBrush;
            }

            // Make sure size of the host and effect visuals always stay in sync
            this._bindSizeAnimation = compositor.CreateExpressionAnimation("hostVisual.Size");
            this._bindSizeAnimation.SetReferenceParameter("hostVisual", hostVisual);
            this._blurVisual.StartAnimation("Size", this._bindSizeAnimation);
        }
Ejemplo n.º 10
0
        public void Dispose()
        {
            _surface.Dispose();
            _surface = null;
            var visual = ElementCompositionPreview.GetElementChildVisual(RootGrid);

            ElementCompositionPreview.SetElementChildVisual(RootGrid, null);
            visual.Dispose();
        }
Ejemplo n.º 11
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var visual = ElementCompositionPreview.GetElementChildVisual(this);

            ElementCompositionPreview.SetElementChildVisual(this, null);
            ElementCompositionPreview.SetElementChildVisual(Frame, visual);

            Frame.GoBack();
        }
Ejemplo n.º 12
0
        void MainGridBlurEffect_SizeChanged(FrameworkElement element)
        {
            var blurVisual = (SpriteVisual)ElementCompositionPreview.GetElementChildVisual(element);

            if (blurVisual != null)
            {
                blurVisual.Size = new Vector2((float)element.ActualWidth, (float)element.ActualHeight);
            }
        }
Ejemplo n.º 13
0
        private void OnSizeChanged(object sender, SizeChangedEventArgs e)
        {
            var blurVisual = (SpriteVisual)ElementCompositionPreview.GetElementChildVisual(BlurContentPresenter);

            if (blurVisual != null)
            {
                blurVisual.Size = e.NewSize.ToVector2();
            }
        }
Ejemplo n.º 14
0
        void MainGridBlurEffect_SizeChanged(FrameworkElement element, SizeChangedEventArgs e)
        {
            var blurVisual = (SpriteVisual)ElementCompositionPreview.GetElementChildVisual(element);

            if (blurVisual != null)
            {
                blurVisual.Size = e.NewSize.ToVector2();
            }
        }
        private void Err_Image_SizeChanged(object sender, SizeChangedEventArgs e)
        {
            SpriteVisual blurVisual = (SpriteVisual)ElementCompositionPreview.GetElementChildVisual(Err_Image);

            if (blurVisual != null)
            {
                blurVisual.Size = e.NewSize.ToVector2();
            }
        }
Ejemplo n.º 16
0
        private void EnsureParent(object uiElement)
        {
            var control = uiElement as UIElement;

            if (control != null && _rootVisual.Parent == null)
            {
                var visual = (SpriteVisual)ElementCompositionPreview.GetElementChildVisual(control);
                visual.Children.InsertAtTop(_rootVisual);
            }
        }
Ejemplo n.º 17
0
        private void OnBackgroundGridSizeChanged(object sender, SizeChangedEventArgs e)
        {
            Visual blur = ElementCompositionPreview.GetElementChildVisual(BackgroundGrid);

            if (blur != null)
            {
                blur.Size = new Vector2((float)BackgroundGrid.ActualWidth, (float)BackgroundGrid.ActualHeight);
                ElementCompositionPreview.SetElementChildVisual(BackgroundGrid, blur);
            }
        }
Ejemplo n.º 18
0
 private void BlurGlass_SizeChanged(object sender, SizeChangedEventArgs e)
 {
     _blurVisual.Size = new Vector2((float)e.NewSize.Width, (float)e.NewSize.Height);
     foreach (var line in new[] { LeftLine, TopLine, RightLine, BottomLine })
     {
         var shadowVisual = ElementCompositionPreview.GetElementChildVisual(line);
         if (shadowVisual == null) continue;
         shadowVisual.Size = new Vector2((float)line.ActualWidth, (float)line.ActualHeight);
     }
 }
Ejemplo n.º 19
0
        public void DiscreteVUBar_BackgroundVisualHasBackgroundBrush()
        {
            var elementVisual    = (ContainerVisual)ElementCompositionPreview.GetElementChildVisual(sut);
            var backgroundVisual = (SpriteVisual)elementVisual.Children.First();

            sut.Background = new SolidColorBrush(Colors.OrangeRed);

            var background = (CompositionColorBrush)backgroundVisual.Brush;

            Assert.AreEqual(Colors.OrangeRed, background.Color);
        }
Ejemplo n.º 20
0
        public void StartEntranceEffect()
        {
            ContainerVisual container  = (ContainerVisual)ElementCompositionPreview.GetElementChildVisual(BasePage);
            Compositor      compositor = container.Compositor;

            // 设置缩放和动画
            const float               ScaleFactor = 20f;
            TimeSpan                  duration    = TimeSpan.FromMilliseconds(1200);
            LinearEasingFunction      linearEase  = compositor.CreateLinearEasingFunction();
            CubicBezierEasingFunction easeInOut   = compositor.CreateCubicBezierEasingFunction(new Vector2(.38f, 0f), new Vector2(.45f, 1f));

            // 创建淡出动画
            ScalarKeyFrameAnimation fadeOutAnimation = compositor.CreateScalarKeyFrameAnimation();

            fadeOutAnimation.InsertKeyFrame(1, 0);
            fadeOutAnimation.Duration = duration;

            // Grid的动画
            Vector2KeyFrameAnimation scaleUpGridAnimation = compositor.CreateVector2KeyFrameAnimation();

            scaleUpGridAnimation.InsertKeyFrame(0.1f, new Vector2(1 / ScaleFactor, 1 / ScaleFactor));
            scaleUpGridAnimation.InsertKeyFrame(1, new Vector2(1, 1));
            scaleUpGridAnimation.Duration = duration;

            // 初始屏动画
            Vector2KeyFrameAnimation scaleUpSplashAnimation = compositor.CreateVector2KeyFrameAnimation();

            scaleUpSplashAnimation.InsertKeyFrame(0, new Vector2(1, 1));
            scaleUpSplashAnimation.InsertKeyFrame(1, new Vector2(ScaleFactor, ScaleFactor));
            scaleUpSplashAnimation.Duration = duration;

            // 设置Grid的中心缩放视觉
            Visual gridVisual = ElementCompositionPreview.GetElementVisual(UIToShow);

            gridVisual.Size        = UIToShow.ActualSize;
            gridVisual.CenterPoint = new Vector3(gridVisual.Size.X, gridVisual.Size.Y, 0) * .5f;

            // 创建一个视觉组,当改组所有视觉执行完后不再显示
            CompositionScopedBatch batch = compositor.CreateScopedBatch(CompositionBatchTypes.Animation);

            container.StartAnimation("Opacity", fadeOutAnimation);
            container.StartAnimation("Scale.XY", scaleUpSplashAnimation);
            gridVisual.StartAnimation("Scale.XY", scaleUpGridAnimation);

            batch.Completed += (s, a) =>
            {
                ElementCompositionPreview.SetElementChildVisual(BasePage, null);
                SurfaceLoader.Uninitialize();
                AnimationCompleted?.Invoke(this, null);
            };
            batch.End();
        }
Ejemplo n.º 21
0
        private void HideCustomSplashScreen()
        {
            ContainerVisual container  = (ContainerVisual)ElementCompositionPreview.GetElementChildVisual(this);
            Compositor      compositor = container.Compositor;

            // Setup some constants for scaling and animating
            const float               ScaleFactor = 20f;
            TimeSpan                  duration    = TimeSpan.FromMilliseconds(1200);
            LinearEasingFunction      linearEase  = compositor.CreateLinearEasingFunction();
            CubicBezierEasingFunction easeInOut   = compositor.CreateCubicBezierEasingFunction(new Vector2(.38f, 0f), new Vector2(.45f, 1f));

            // Create the fade animation which will target the opacity of the outgoing splash screen
            ScalarKeyFrameAnimation fadeOutAnimation = compositor.CreateScalarKeyFrameAnimation();

            fadeOutAnimation.InsertKeyFrame(1, 0);
            fadeOutAnimation.Duration = duration;

            // Create the scale up animation for the grid
            Vector2KeyFrameAnimation scaleUpGridAnimation = compositor.CreateVector2KeyFrameAnimation();

            scaleUpGridAnimation.InsertKeyFrame(0.1f, new Vector2(1 / ScaleFactor, 1 / ScaleFactor));
            scaleUpGridAnimation.InsertKeyFrame(1, new Vector2(1, 1));
            scaleUpGridAnimation.Duration = duration;

            // Create the scale up animation for the Splash screen visuals
            Vector2KeyFrameAnimation scaleUpSplashAnimation = compositor.CreateVector2KeyFrameAnimation();

            scaleUpSplashAnimation.InsertKeyFrame(0, new Vector2(1, 1));
            scaleUpSplashAnimation.InsertKeyFrame(1, new Vector2(ScaleFactor, ScaleFactor));
            scaleUpSplashAnimation.Duration = duration;

            // Configure the grid visual to scale from the center
            Visual gridVisual = ElementCompositionPreview.GetElementVisual(MainFrame);

            gridVisual.Size        = new Vector2((float)MainFrame.ActualWidth, (float)MainFrame.ActualHeight);
            gridVisual.CenterPoint = new Vector3(gridVisual.Size.X, gridVisual.Size.Y, 0) * .5f;


            //
            // Create a scoped batch for the animations.  When the batch completes, we can dispose of the
            // splash screen visuals which will no longer be visible.
            //

            CompositionScopedBatch batch = compositor.CreateScopedBatch(CompositionBatchTypes.Animation);

            container.StartAnimation("Opacity", fadeOutAnimation);
            container.StartAnimation("Scale.XY", scaleUpSplashAnimation);
            gridVisual.StartAnimation("Scale.XY", scaleUpGridAnimation);

            batch.Completed += Batch_Completed;
            batch.End();
        }
Ejemplo n.º 22
0
        protected override void OnDetaching()
        {
            base.OnDetaching();

            var element = AssociatedObject as UIElement;

            if (element != null)
            {
                var visual = ElementCompositionPreview.GetElementChildVisual(element) ??
                             ElementCompositionPreview.GetElementVisual(element);
                visual.ImplicitAnimations = null;
            }
        }
        private static void AnimationSet_Completed(object sender, EventArgs e)
        {
            var animationSet = sender as AnimationSet;

            animationSet.Completed -= AnimationSet_Completed;

            var spriteVisual = ElementCompositionPreview.GetElementChildVisual(animationSet.Element) as SpriteVisual;
            var blurBrush    = spriteVisual?.Brush as CompositionEffectBrush;

            if (blurBrush != null && blurBrush.Comment == "Blur")
            {
                spriteVisual.Brush = null;
            }
        }
Ejemplo n.º 24
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // Remove the visual from the page and place it on the window content so that
            // it survives the page transition.
            var visual = ElementCompositionPreview.GetElementChildVisual(this);

            ElementCompositionPreview.SetElementChildVisual(this, null);
            ElementCompositionPreview.SetElementChildVisual(
                Window.Current.Content,
                visual);

            // Navigate to the next page.
            Frame.Navigate(typeof(SecondaryPage));
        }
        /// <summary>
        /// Shows the content.
        /// </summary>
        /// <param name="page">The page.</param>
        private static void ShowContent(Page page)
        {
            var container  = (ContainerVisual)ElementCompositionPreview.GetElementChildVisual(page);
            var compositor = container.Compositor;

            // Setup some constants for scaling and animating
            const float scaleFactor = 7.5f;
            var         duration    = TimeSpan.FromMilliseconds(2000);

            // Create the fade animation which will target the opacity of the outgoing splash screen
            var fadeOutAnimation = compositor.CreateScalarKeyFrameAnimation();

            fadeOutAnimation.InsertKeyFrame(1, 0);
            fadeOutAnimation.Duration = duration;

            // Optional: zoom in content.
            // Create the scale up animation for the grid
            //var scaleUpGridAnimation = compositor.CreateVector2KeyFrameAnimation();
            //scaleUpGridAnimation.InsertKeyFrame(0.1f, new Vector2(1 / scaleFactor, 1 / scaleFactor));
            //scaleUpGridAnimation.InsertKeyFrame(1, new Vector2(1, 1));
            //scaleUpGridAnimation.Duration = duration;

            // Create the scale up animation for the Splash screen visuals
            var scaleUpSplashAnimation = compositor.CreateVector2KeyFrameAnimation();

            scaleUpSplashAnimation.InsertKeyFrame(0, new Vector2(1, 1));
            scaleUpSplashAnimation.InsertKeyFrame(1, new Vector2(scaleFactor, scaleFactor));
            scaleUpSplashAnimation.Duration = duration;

            // Configure the visual to scale from the center
            var frameworkElement = page.Content as FrameworkElement;
            var visual           = ElementCompositionPreview.GetElementVisual(frameworkElement);

            visual.Size        = new Vector2((float)frameworkElement.ActualWidth, (float)frameworkElement.ActualHeight);
            visual.CenterPoint = new Vector3(visual.Size.X, visual.Size.Y, 0) * .5f;

            //
            // Create a scoped batch for the animations.  When the batch completes, we can dispose of the
            // splash screen visuals which will no longer be visible.
            //
            var batch = compositor.CreateScopedBatch(CompositionBatchTypes.Animation);

            container.StartAnimation("Opacity", fadeOutAnimation);
            container.StartAnimation("Scale.XY", scaleUpSplashAnimation);
            // visual.StartAnimation("Scale.XY", scaleUpGridAnimation);

            currentPage      = page; // TODO: find a better way to pass the page to the event.
            batch.Completed += Batch_Completed;
            batch.End();
        }
Ejemplo n.º 26
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // Before going back to the MainPage, remove the visual from thsi page and place
            // it on the window content so it survives the page transition.
            var visual = ElementCompositionPreview.GetElementChildVisual(this);

            ElementCompositionPreview.SetElementChildVisual(this, null);
            ElementCompositionPreview.SetElementChildVisual(
                Window.Current.Content,
                visual);

            // Go back to our MainPage.
            Frame.GoBack();
        }
Ejemplo n.º 27
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            var visual = ElementCompositionPreview.GetElementChildVisual(Frame);

            ElementCompositionPreview.SetElementChildVisual(Frame, null);
            ElementCompositionPreview.SetElementChildVisual(this, visual);

            var offsetAnimation = visual.Compositor.CreateVector3KeyFrameAnimation();

            offsetAnimation.InsertKeyFrame(0, visual.Offset);
            offsetAnimation.InsertKeyFrame(1f, new System.Numerics.Vector3((float)(Frame.ActualHeight - 200), visual.Offset.Y, visual.Offset.Z));
            offsetAnimation.Duration = TimeSpan.FromMilliseconds(3000);
            visual.StartAnimation(nameof(visual.Offset), offsetAnimation);
        }
Ejemplo n.º 28
0
        protected override void OnAttached()
        {
            base.OnAttached();

            var element = AssociatedObject as UIElement;

            if (element != null)
            {
                EnsureImplicitAnimations(element);
                // Check to see if the element has a SpriteVisual - assumption being that is what is going to be sized
                var visual = ElementCompositionPreview.GetElementChildVisual(element) ??
                             ElementCompositionPreview.GetElementVisual(element);
                visual.ImplicitAnimations = _implicitAnimations;
            }
        }
Ejemplo n.º 29
0
        public static ContainerVisual GetContainerVisual(this UIElement element, bool linkSize = true)
        {
            if (element == null)
                return null;

            if (ElementCompositionPreview.GetElementChildVisual(element) is ContainerVisual container)
                return container;

            // Create a new container visual, link it's size to the element's and then set
            // the container as the child visual of the element.
            container = GetElementVisual(element).Compositor.CreateContainerVisual();
            CompositionExtensions.LinkSize(container, GetElementVisual(element));
            element.SetChildVisual(container);

            return container;
        }
Ejemplo n.º 30
0
        public void StartEntranceEffect()
        {
            try
            {
                TimeSpan AnimationDuration = TimeSpan.FromMilliseconds(1000);

                ContainerVisual Container = (ContainerVisual)ElementCompositionPreview.GetElementChildVisual(BasePage);

                ScalarKeyFrameAnimation FadeOutAnimation = Container.Compositor.CreateScalarKeyFrameAnimation();
                FadeOutAnimation.InsertKeyFrame(1, 0);
                FadeOutAnimation.Duration = AnimationDuration;

                Vector2KeyFrameAnimation ScaleUIAnimation = Container.Compositor.CreateVector2KeyFrameAnimation();
                ScaleUIAnimation.InsertKeyFrame(0.1f, new Vector2(1 / ScaleFactor, 1 / ScaleFactor));
                ScaleUIAnimation.InsertKeyFrame(1, new Vector2(1, 1));
                ScaleUIAnimation.Duration = AnimationDuration;

                Vector2KeyFrameAnimation ScaleSplashAnimation = Container.Compositor.CreateVector2KeyFrameAnimation();
                ScaleSplashAnimation.InsertKeyFrame(0, new Vector2(1, 1));
                ScaleSplashAnimation.InsertKeyFrame(1, new Vector2(ScaleFactor, ScaleFactor));
                ScaleSplashAnimation.Duration = AnimationDuration;

                Visual UIVisual = ElementCompositionPreview.GetElementVisual(UIToShow);
                UIVisual.Size        = new Vector2((float)UIToShow.ActualWidth, (float)UIToShow.ActualHeight);
                UIVisual.CenterPoint = new Vector3(UIVisual.Size.X, UIVisual.Size.Y, 0) * 0.5f;


                CompositionScopedBatch BatchAnimation = Container.Compositor.CreateScopedBatch(CompositionBatchTypes.Animation);

                Container.StartAnimation("Opacity", FadeOutAnimation);
                Container.StartAnimation("Scale.XY", ScaleSplashAnimation);
                UIVisual.StartAnimation("Scale.XY", ScaleUIAnimation);

                BatchAnimation.Completed += (s, a) =>
                {
                    ElementCompositionPreview.SetElementChildVisual(BasePage, null);
                    SurfaceLoader.Uninitialize();
                    AnimationCompleted?.Invoke(this, null);
                };

                BatchAnimation.End();
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"Error in StartEntranceEffect, message:{ex.Message}");
            }
        }