Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 异步调用情节提要_C#_Wpf - Fatal编程技术网

C# 异步调用情节提要

C# 异步调用情节提要,c#,wpf,C#,Wpf,我的窗口有一个长方形。如果我将鼠标移向窗口的右角,我将使用MouseMove检测鼠标位置并触发名为AnimateRight()的动画,该动画将矩形水平向右平移 但是,在这个动画中,如果鼠标移动到窗口的中心,我希望锐角停止平移,只停留在停止的位置 我该怎么做 private void AnimateRight() { DoubleAnimation da = new DoubleAnimation(); da.Duration = Tim

我的窗口有一个长方形。如果我将鼠标移向窗口的右角,我将使用MouseMove检测鼠标位置并触发名为AnimateRight()的动画,该动画将矩形水平向右平移

但是,在这个动画中,如果鼠标移动到窗口的中心,我希望锐角停止平移,只停留在停止的位置

我该怎么做

private void AnimateRight()
    {

            DoubleAnimation da = new DoubleAnimation();

            da.Duration = TimeSpan.FromSeconds(2);

            da.From = 0;

            da.To = 200;

            TransformGroup transGroup = new TransformGroup();
            transGroup.Children.Add(new TranslateTransform());
            gr.RenderTransform = transGroup;


            Storyboard.SetTarget(da, gr);
            Storyboard.SetTargetProperty(da, new PropertyPath("RenderTransform.Children[0].X"));

            sb.AccelerationRatio = 0.8;
            sb.Children.Add(da);
            sb.Begin();

    }

您是否尝试暂停情节提要?是否尝试暂停情节提要?