有条件的触发器WPF [英] Conditional triggers WPF
问题描述
大家好,
我仍然对WPF中的触发器感到困惑,所以请帮忙.我在这里完全迷路了.以下是我的代码的一部分.
Hello All,
I still get a bit confused wen it comes to triggers in WPF so please help.I am totally lost here .Following is part of my code.
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
I want to put a condition here saying if select button is clicked(the select button is a ribbon toggle button) then only on mouse over the decorator shoulds be visble
</MultiDataTrigger.Conditions>
<Setter TargetName="Decorator" Property="Visibility" Value="Visible"/>
</MultiDataTrigger>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Decorator" Property="Visibility" Value="Visible"/>
</Trigger>
我希望我对这个问题很清楚.功能区按钮在另一个xaml文件中
我想要的就是在鼠标悬停上单击功能区按钮选择"后,装饰器应该可见,否则隐藏,如果我们可以在按钮后面的代码中执行此操作,也可以单击确定,但是我不确定如何更改在另一个按钮上设置的属性xaml文件.
在此先感谢
I hope I am clear with this question.the ribbon button is in another xaml file
All I want is after I click the ribbon button "select" on mouseover the decorator shoulds be visible else hidden if we can do this in code behind on button click also ok but I am not sure how to change the property that is set on another xaml file.
Thanks in advance
推荐答案
通过将资源文件添加到项目中来创建样式资源
在该资源中,定义功能区按钮的样式,然后在style.trigger上定义装饰器的可见性属性
希望这对您有帮助.
Hi,
Create a style resource by adding resource file to your project
In that resource define a style for the ribbon button and on style.trigger define your decorator visibility proeprty
Hope this helps.
如果您希望在上的条件属性,则可以使用 MultiTrigger .
如果您对属性没有依赖性,则可以使用 MultiDataTrigger .
If your have conditions on properties the aren''t Dependency Properties, you can use a MultiDataTrigger.
在有关它们的MSDN主题中有使用这些触发器的示例.
There are examples of the use of these triggers in the MSDN topics about them.
这篇关于有条件的触发器WPF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!