我有弹出窗口,我有一个使用其水平和垂直偏移量的动画。此动画将这些偏移量作为值并具有简单的故事板。第一次它工作正常,第二次,水平偏移没有更新值。我不知道为什么会这样。我已经用属性更改的处理程序检查了 Dp,它没有被更改。保留其旧值。根本没有绑定,直接设置值。
这可能是什么原因。对此有任何想法吗?
var duration = new TimeSpan(0, 0, 0, 0, 200);
horizontalDoubleAnimation = new EasingDoubleKeyFrame();
verticalDoubleAnimation = new EasingDoubleKeyFrame();
horizontalDoubleAnimation.KeyTime = KeyTime.FromTimeSpan(duration);
verticalDoubleAnimation.KeyTime = KeyTime.FromTimeSpan(duration);
horizontalDoubleAnimation.EasingFunction = new CircleEase();
verticalDoubleAnimation.EasingFunction = new CircleEase();
DoubleAnimationUsingKeyFrames horizontalAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames();
DoubleAnimationUsingKeyFrames verticalAnimationUsingKeyFrames = new DoubleAnimationUsingKeyFrames();
horizontalAnimationUsingKeyFrames.KeyFrames.Add(horizontalDoubleAnimation);
verticalAnimationUsingKeyFrames.KeyFrames.Add(verticalDoubleAnimation);
reverseAnimationStoryboard = new Storyboard { Duration = duration };
reverseAnimationStoryboard.Children.Add(horizontalAnimationUsingKeyFrames);
reverseAnimationStoryboard.Children.Add(verticalAnimationUsingKeyFrames);
Storyboard.SetTarget(horizontalAnimationUsingKeyFrames, this.DraggablePopup);
Storyboard.SetTarget(verticalAnimationUsingKeyFrames, this.DraggablePopup);
Storyboard.SetTargetProperty(horizontalAnimationUsingKeyFrames, new PropertyPath("HorizontalOffset"));
Storyboard.SetTargetProperty(verticalAnimationUsingKeyFrames, new PropertyPath("VerticalOffset"));
this.DraggablePopup.Resources.Add("storyboard", reverseAnimationStoryboard);