2013-04-22 95 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感興趣。該綁定計爲「本地值」,並且優先級低於動畫。

相關問題