6
votes

If I have a BooleanAnimation that sets a property, that property becomes locked and can't be changed by any other means.

Example:

<EventTrigger
    SourceName="myButton"
    RoutedEvent="Button.Click">
    <EventTrigger.Actions>
        <BeginStoryboard>
            <Storyboard>
                <BooleanAnimationUsingKeyFrames
                    Storyboard.TargetName="myCheckBox"
                    Storyboard.TargetProperty="IsChecked"
                    FillBehavior="HoldEnd">
                    <DiscreteBooleanKeyFrame
                        KeyTime="00:00:00"
                        Value="False" />
                </BooleanAnimationUsingKeyFrames>
            </Storyboard>
        </BeginStoryboard>
    </EventTrigger.Actions>
</EventTrigger>

In this example, if the button is clicked the checkbox is set to false, however, if the user attempts to check the checkBox again the checkbox is unresponsive. The IsChecked property can't be set through code either (after the button has been clicked).

I can create another animation that will update the CheckBox, but that's not the behavior I require.

I've also tried FillBehavior="Stop", but that just causes the Animation not to work either.

2

2 Answers

7
votes

The CheckBox is still being set, but the animation is still running, which is why it appears to be unchecking it. There are a few ways that this can be fixed so that the animation no longer controls the property on the checkbox. The MSDN Animation overview talks about what happens when the animation ends. And how to set a Property after animating it with a Storyboard goes over some other options.

2
votes

replace

FillBehavior="HoldEnd"

with

Duration="00:00:01" FillBehavior="Stop"

and it will work :-)