C# 依赖属性';s集不';不要更新它的值

C# 依赖属性';s集不';不要更新它的值,c#,wpf,xaml,animation,C#,Wpf,Xaml,Animation,我有一个弹出窗口,我有一个使用其水平和垂直偏移的动画。此动画将这些偏移作为值,并具有简单的情节提要。第一次工作正常,第二次,水平偏移没有更新该值。我不知道为什么是这样。我已经用属性已更改的处理程序检查了Dp,它不会被更改。保留其原有价值。根本没有绑定,直接设置值 原因可能是什么。有什么想法吗 var duration = new TimeSpan(0, 0, 0, 0, 200); horizontalDoubleAnimation = new EasingDou

我有一个弹出窗口,我有一个使用其水平和垂直偏移的动画。此动画将这些偏移作为值,并具有简单的情节提要。第一次工作正常,第二次,水平偏移没有更新该值。我不知道为什么是这样。我已经用属性已更改的处理程序检查了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);

this.DraggablePopup.horizontalcoffset=Math.Round(horizontalcoffset)<代码>水平偏移量
它只是一个双倍值。垂直偏移量在第一次之后有效吗?您在何处以及如何更新垂直偏移和水平偏移?第一次更新后不会更新。。当鼠标移动时,我正在更新。@fhnania:有什么想法吗?您还没有显示任何设置任何值的代码。这段代码正在创建情节提要并将其保存为资源,但没有运行它(这将导致设置值)。您是否反复运行此代码并期望发生什么事情?