ImplicitAnimation UWP时的人工制品

时间:2017-08-31 15:07:22

标签: c# uwp win2d

我的ImplicitAnimation存在问题。 当网格上升时,一切看起来都很好,但是当方法CloseButton_Click进行并且网格出现故障时,人工制品会像图像Artefacts中那样。有谁知道如何修理它?我会对每一个想法都感激不尽。

我的代码如下所示:

public sealed partial class AddTaskView : UserControl
{
    private Compositor _compositor;
    private Visual myWindow;
    private Vector3KeyFrameAnimation offsetAnimation;
    private ImplicitAnimationCollection implicitAnimation;
    public AddTaskView()
    {
        this.InitializeComponent();
        this.InitializeTransition();
    }

    private void InitializeTransition()
    {
        WindowGrid.Height = ((Frame)Window.Current.Content).ActualHeight;
        WindowGrid.Width = ((Frame)Window.Current.Content).ActualWidth;
        myWindow = ElementCompositionPreview.GetElementVisual(myWindowGrid);
        _compositor = myWindow.Compositor;
        myWindow.Size = new Vector2((float)((Frame)Window.Current.Content).ActualWidth
            , (float)((Frame)Window.Current.Content).ActualHeight);
    }

    private void ColorSlideTransitionCompleted(object sender, EventArgs e)
    {
    }

    private void UserControl_Loaded(object sender, RoutedEventArgs e)
    {
        myWindow.Size = new Vector2((float)((Frame)Window.Current.Content).ActualWidth
            , (float)((Frame)Window.Current.Content).ActualHeight);
        myWindow.Offset = new Vector3(0.0f, (float)WindowGrid.ActualHeight, 0.0f);
        offsetAnimation = _compositor.CreateVector3KeyFrameAnimation();
        offsetAnimation.Target = nameof(Visual.Offset);
        offsetAnimation.InsertExpressionKeyFrame(1.0f, "this.FinalValue");
        offsetAnimation.Duration = TimeSpan.FromMilliseconds(5000);


        implicitAnimation = _compositor.CreateImplicitAnimationCollection();
        implicitAnimation[nameof(Visual.Offset)] = offsetAnimation;
        myWindow.ImplicitAnimations = implicitAnimation;
        #region slide
        myWindow.Offset = new Vector3(0.0f, 0.0f, 0.0f);
        #endregion
    }


    private void CloseButton_Click(object sender, RoutedEventArgs e)
    {
        myWindow.Offset = new Vector3(0.0f, (float)((Frame)Window.Current.Content).ActualHeight, 0.0f);
    }
}

OffTopic :稍后,我想将此动画与GaussianBlurEffect连接起来。有可能吗?你有什么提示吗?我也要感激。

0 个答案:

没有答案