简体   繁体   中英

Control stops working after animating it

I have a slider named 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

    <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. The default is 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM