简体   繁体   English

设置动画后,控件停止工作

[英]Control stops working after animating it

I have a slider named tbMaster : 我有一个名为tbMaster的滑块:

<Slider  Name="tbMaster"  Maximum="10000"  Value="{Binding SbVolumeValue}"/>

code behind for binded property: 绑定属性后面的代码:

    double _SbVolumeValue;
    public double SbVolumeValue
    {
        get
        {
            return _SbVolumeValue;
        }
        set
        {
            _SbVolumeValue = value;
            OnPropertyChanged("SbVolumeValue");
        }
    }

I have the storyboard sbVolume 我有情节sbVolume

    <Storyboard x:Key="sbVolume">
        <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(RangeBase.Value)" Storyboard.TargetName="tbMaster">
            <EasingDoubleKeyFrame KeyTime="0:0:1.2" Value="40">
                <EasingDoubleKeyFrame.EasingFunction>
                    <CircleEase EasingMode="EaseOut"/>
                </EasingDoubleKeyFrame.EasingFunction>
            </EasingDoubleKeyFrame>
        </DoubleAnimationUsingKeyFrames>
    </Storyboard>

if I run the application the slider works great. 如果我运行该应用程序,则滑块会很好用。 It stops working when I begin the storyboard as: 当我启动情节提要时,它停止工作:

 var sbVolume = this.FindResource("sbVolume") as Storyboard;
 sbVolume.Begin();

why does it stops working after I animate it? 为什么在设置动画后它停止工作?

Try adding a FillBehavior.Stop to your Animation. 尝试将FillBehavior.Stop添加到动画中。 The default is FillBehavior.HoldEnd . 默认值为FillBehavior.HoldEnd

From Above Link: 从上方链接:

Because an animation in its fill period continues to override its target property's value, attempting to set the target property's value through other means might appear to have no effect. 由于动画在其填充期中继续覆盖其目标属性的值,因此尝试通过其他方式设置目标属性的值似乎无效。 For an example showing how to set a property value after it has been animated, see How to: Set a Property After Animating It with a Storyboard. 有关显示属性值动画后如何设置属性的示例,请参见如何:使用情节提要对其进行动画处理后设置属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么在设置动画高度设置后,此属性将直接停止工作 - Why after animating height setting this property directly stops working WPF WebBrowser控件上的onmousemove侦听器在几秒钟后停止工作 - onmousemove listener on WPF WebBrowser control stops working after few seconds 在控件上绘制一些图形后为其动画的子代 - Animating Children Of a Control after drawing some graphics on it 为2D对象设置动画时,Transform.Translate()停止工作 - When animating a 2d object `Transform.Translate()` stops working 在 Uno 2.4 和 WASM 上进行页面导航后,ProgressRing 停止动画 - ProgressRing stops animating after a page navigation on Uno 2.4 & WASM 控制面板中的语言设置更改后,C#程序停止工作(例如,从英语到德语) - C# program stops working after the language setting in control panel is changed (say, from English to German) WPF Bing Maps控件:设置属性后,鼠标滚动停止工作 - WPF Bing Maps control: mouse scroll stops working after setting properties 一段时间后,RelayCommand停止工作 - RelayCommand stops working after a while LinearGradientBrush中的错误动画停止停止 - Inconsistent Error Animating Stops in a LinearGradientBrush Google身份验证会在一段时间后停止工作 - Google Authentication stops working after some time
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM