【问题标题】:Binding and VisualStateManager do not work togetherBinding 和 VisualStateManager 不能一起工作
【发布时间】:2013-04-22 06:54:58
【问题描述】:

我有VisualStateManager来控制当State发生时,控制是启用的:

这里是状​​态的属性(字符串):

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

这里是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>

这是我的文本框:

<TextBox Name="MyTextBox" />

我的问题是:当我将 TextBox 添加到以下行时会发生什么:

IsEnable= {Binding isProp}// isProp = bool

在我看来,它消除了TextBoxIsEnable 而不是指他,只指State

这是真的吗?有没有一种方法可以同时工作?

【问题讨论】:

    标签: wpf binding visualstatemanager


    【解决方案1】:

    在您的情况下,动画将优先于绑定,但前提是动画的时间轴正在运行。即当视觉状态为“MyName”时,动画将控制IsEnabled属性;否则,绑定将。

    您可能对此Dependency Property Value Precedence 列表感兴趣。绑定算作“本地值”,优先级低于动画。

    【讨论】:

      猜你喜欢
      • 2016-10-12
      • 1970-01-01
      • 2013-08-09
      • 1970-01-01
      • 1970-01-01
      • 2014-01-07
      • 2019-08-17
      • 2016-11-23
      • 2019-02-18
      相关资源
      最近更新 更多