2013-04-22 58 views
1

VisualStateManager当国家发生的控制,控制有效:绑定和VisualStateManager不共同努力

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

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" /> 

我的问题是:会发生什么事,当我添加文本框下面一行:

IsEnable= {Binding isProp}// isProp = bool 

我看到它的方式,它消除了TextBoxIsEnable并没有提到他,只为State

这是真的吗?他们都有办法吗?

回答

2

在你的情况下,动画将优先于绑定,但只有动画的时间轴正在运行。也就是说,当视觉状态是“MyName”时,动画将控制IsEnabled属性;否则,绑定会。

您可能会对此列表Dependency Property Value Precedence感兴趣。该绑定计为“本地值”,并且优先级低于动画。