Expression Blend 交互:如何设置触发器来查找按钮的 IsEnabled 值?
我是一名使用 Expression Blend 4 的设计师,我们的环境是 .NET 3.5。
这个问题对你们来说可能很简单,但对我来说却是一个很大的问题。
我需要对按钮应用交互,该交互将在按钮启用时触发状态。
在按钮上,开发人员有一个与 IsEnabled 属性关联的布尔值。我必须为 EventTrigger 提供 EventName,而我唯一能想到的是 IsEnabledChanged。但是,当我运行该应用程序时,这没有任何作用。
如何告诉触发器查找按钮 IsEnabled 属性的布尔值的变化?
这是代码:
<Button x:Name="SaveButton"
Command="{Binding SaveCommand}"
IsEnabled="{Binding IsSaveAllowedBool}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="IsEnabledChanged">
<ic:GoToStateAction StateName="MyState"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
I am a designer using Expression Blend 4 and our environment is .NET 3.5.
This issue may be simple to you guys, but it is causing me quite a problem.
I need to apply an interaction to a button that will trigger a state when the button becomes enabled.
On the button, the developer has a Boolean value associated with the IsEnabled property. I have to supply the EventTrigger with an EventName, and the only thing that I can think of is IsEnabledChanged. However, when I run the app, this does nothing.
How do I tell the Trigger to look for a change in the Boolean value of the IsEnabled property of the button?
Here is the code:
<Button x:Name="SaveButton"
Command="{Binding SaveCommand}"
IsEnabled="{Binding IsSaveAllowedBool}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="IsEnabledChanged">
<ic:GoToStateAction StateName="MyState"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了解决问题的方法。
我在
Border
元素周围包裹了一个ContentControl
,我试图根据布尔值使其出现/消失(我这样做是为了修改ControlTemplate< /code> -
Border
元素没有与之关联的ControlTemplate
)然后我绑定了
ContentControl< 的
IsEnabled
属性/code> 为相同的 bool开发商有。我修改了ContentControl
的ControlTemplate
,使其具有一个在布尔值更改时触发的Trigger
。这是代码:
这个解决方案运行得很好。只是想我会分享。
I found a solution to my problem.
I wrapped a
ContentControl
around theBorder
element that I am trying to make appear/disappear based on the Boolean value (I did this in order to modify aControlTemplate
- theBorder
element does not have aControlTemplate
associated with it)Then I bound the
IsEnabled
property of theContentControl
to the same bool the developer had. I modified theControlTemplate
of theContentControl
to have aTrigger
that would fire when the Boolean value changed.Here is the code:
This solution worked perfectly. Just thought I'd share.