防爆pression混合互动:如何设置触发,以寻找按钮的IsEnabled价值? [英] Expression Blend Interaction: How to set Trigger to Look for IsEnabled Value of Button?
问题描述
我用防爆pression混合4的设计者和我们的环境是.NET 3.5。
此问题可能是简单,你们这些家伙,但它使我相当有问题。
我需要一个交互应用到一个按钮,当按钮被启用,这将触发状态。
在该按钮时,开发者与IsEnabled属性关联的布尔值。我必须与事件名称提供的EventTrigger,那我能想到的唯一的事情就是IsEnabledChanged。然而,当我运行应用程序,这什么也不做。
我如何告诉触发寻找在按钮的IsEnabled属性?
的布尔值的变化下面是code:
<按钮X:NAME =SaveButton
命令={结合SaveCommand}
IsEnabled ={结合IsSaveAllowedBool}>< I:Interaction.Triggers>
< I:的EventTrigger事件名称=IsEnabledChanged>
< IC:GoToStateAction Statename的=MyState/>
< /我:&的EventTrigger GT;
< /我:Interaction.Triggers>< /按钮>
我找到了解决我的问题。
我包裹Border元素周围ContentControl中,我试图让显示/基于布尔值消失。 (我以修改控件模板这样做 - 边框元素没有与它相关的控制模板)
然后我绑定的ContentControl中的IsEnabled属性相同的布尔开发商了。我修改了ContentControl中的ControlTemplate中有一个触发时,布尔值改变,将触发。
下面是code:
<风格X:键=MyContentControl的TargetType ={X:类型ContentControl中}>
< setter属性=模板>
< Setter.Value>
<的ControlTemplate的TargetType ={X:类型ContentControl中}>
<内容presenter /> < ControlTemplate.Triggers>
<触发属性=IsEnabledVALUE =FALSE>
< setter属性=能见度VALUE =折叠/> < /触发> < /ControlTemplate.Triggers>
< /控件模板>
< /Setter.Value>
< /二传手>
< /样式和GT;
< ContentControl中风格={DynamicResource MyContentControl}
IsEnabled ={结合IsSaveAllowedBool}> <! - 所有我的内容 - >< / ContentControl中>
该解决方案完美地工作。只是想我会分享。
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>
I found a solution to my problem.
I wrapped a ContentControl around the Border element that I am trying to make appear/disappear based on the Boolean value. (I did this in order to modify a control template - the Border element does not have a control template associated with it)
Then I bound the IsEnabled property of the ContentControl to the same bool the developer had. I modified the ControlTemplate of the ContentControl to have a Trigger that would fire when the Boolean value changed.
Here is the code:
<Style x:Key="MyContentControl" TargetType="{x:Type ContentControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ContentControl}">
<ContentPresenter/>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Visibility" Value="Collapsed"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ContentControl Style="{DynamicResource MyContentControl}"
IsEnabled="{Binding IsSaveAllowedBool}">
<!-- ALL MY CONTENT -->
</ContentControl>
This solution worked perfectly. Just thought I'd share.
这篇关于防爆pression混合互动:如何设置触发,以寻找按钮的IsEnabled价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!