Pregunta

I have VisualStateManager to control when the State occurs, the control is enabled:

Here is the property of the state (string):

states:StateManager.VisualStateProperty="{Binding SomeProp}"

Here the VisualStateManager:

<VisualStateManager.VisualStateGroups>
    <VisualStateGroup x:Name="VisualStateGroup">
        <VisualState x:Name="MyName">
            <Storyboard>                
                <BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.IsEnabled)" Storyboard.TargetName="MyTextBox">
                    <DiscreteBooleanKeyFrame KeyTime="0" Value="True" />
                </BooleanAnimationUsingKeyFrames>
            </Storyboard>
        </VisualState>
        <VisualState x:Name="HerName">
            <Storyboard>
               ...
            </Storyboard>
        </VisualState>
        <VisualState x:Name="This">
            <Storyboard>
               ...
            </Storyboard>
        </VisualState>
    </VisualStateGroup>
</VisualStateManager.VisualStateGroups>

Here my text box:

<TextBox Name="MyTextBox" />

My question is: What happens when I add the TextBox the following line:

IsEnable= {Binding isProp}// isProp = bool

The way I see it, it eliminates the IsEnable of the TextBox and not refers to him, only to State.

Is this true? And is there a way they both work?

¿Fue útil?

Solución

In your case, the Animation will take precedence over the binding, but only as long as the Animation's timeline is running. That is, when the visual state is "MyName", the animation will control the IsEnabled property; otherwise, the binding will.

You may be interested in this list of Dependency Property Value Precedence. The binding counts as a "Local value" and is of lower precedence than the animation.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top