Wpf 绑定和VisualStateManager不能一起工作
我有Wpf 绑定和VisualStateManager不能一起工作,wpf,binding,visualstatemanager,Wpf,Binding,Visualstatemanager,我有VisualStateManager来控制当状态发生时,控件将启用: 以下是状态的属性(字符串): 这里是VisualStateManager: <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="VisualStateGroup"> <VisualState x:Name="MyName"> <Storyboard>
VisualStateManager
来控制当状态发生时,控件将启用:
以下是状态的属性(字符串):
这里是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>
在我看来,它消除了文本框的IsEnable
,而不是指他,只是指状态
这是真的吗?它们是否都有一种工作方式?在您的情况下,动画将优先于绑定,但前提是动画的时间线正在运行。也就是说,当视觉状态为“MyName”时,动画将控制IsEnabled属性;否则,绑定将失败
你可能会对这份清单感兴趣。绑定计为“局部值”,优先级低于动画
<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