Ejemplo n.º 1
0
        protected override void OnConnected(UIElement element)
        {
            var host  = ElementCompositionPreview.GetElementVisual(element);
            var group = host.Compositor.CreateAnimationGroup();

            var step = host.Compositor.CreateStepEasingFunction();

            scale = host.Compositor.CreateVector3KeyFrameAnimation();
            scale.InsertExpressionKeyFrame(0f, "this.StartingValue");
            scale.InsertExpressionKeyFrame(0.99f, "Vector3(scalex,scaley,1f)");
            scale.InsertExpressionKeyFrame(1f, "this.FinalValue", step);
            scale.SetReferenceParameter("host", host);
            scale.SetScalarParameter("scalex", (float)ScaleX);
            scale.SetScalarParameter("scaley", (float)ScaleY);
            scale.Duration = Duration;
            scale.Target   = "Scale";

            opacity = host.Compositor.CreateScalarKeyFrameAnimation();
            opacity.InsertExpressionKeyFrame(0f, "this.StartingValue");
            opacity.InsertKeyFrame(0.99f, 0f);
            opacity.InsertKeyFrame(1f, 0f, step);
            opacity.Duration = Duration;
            opacity.Target   = "Opacity";

            group.Add(scale);
            group.Add(opacity);

            Animation = group;
        }
        protected override void OnConnected(UIElement element)
        {
            var host  = ElementCompositionPreview.GetElementVisual(element);
            var group = host.Compositor.CreateAnimationGroup();

            offset = host.Compositor.CreateVector3KeyFrameAnimation();
            offset.InsertExpressionKeyFrame(0f, "Vector3(this.StartingValue.X + offsetx,this.StartingValue.Y + offsety,this.StartingValue.Z)");
            offset.InsertExpressionKeyFrame(1f, "this.FinalValue");
            offset.SetReferenceParameter("host", host);
            offset.SetScalarParameter("offsetx", (float)OffsetX);
            offset.SetScalarParameter("offsety", (float)OffsetY);
            offset.Duration = Duration;
            offset.Target   = "Offset";

            opacity = host.Compositor.CreateScalarKeyFrameAnimation();
            opacity.InsertKeyFrame(0f, 0f);
            opacity.InsertExpressionKeyFrame(1f, "this.FinalValue");
            opacity.Duration = Duration;
            opacity.Target   = "Opacity";

            group.Add(offset);
            group.Add(opacity);

            Animation = group;
        }