依赖项属性的集合不会更新其值

时间:2013-04-29 17:29:24

标签: c# wpf xaml animation

我有弹出窗口,我有一个使用水平和垂直偏移的动画。此动画将这些偏移量作为值并具有简单的故事板。第一次它工作正常,第二次,水平偏移没有更新值。我不喜欢这样的原因。我已经用属性更改处理程序检查了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);

0 个答案:

没有答案
相关问题