您可以将路由事件与 MultiTrigger 一起使用吗?
WPF 是否支持使用响应路由事件但仅满足条件的触发器?
例如,WPF 支持通过事件触发器触发路由事件。 即:
<Button>
<Button.Triggers>
<EventTrigger RoutedEvent="Click">
...
</..
</..
</..
但是,我正在寻找仅在满足特定条件时才会触发的触发器。 通常,您使用 MultiTriggers 来满足多个条件。 即:
<Button>
<Button.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="..." Value="..."/>
<Condition Binding="..." Value="..."/>
</..
</..
</..
</..
但是 MultiTrigger 或 MultiDataTrigger 似乎都不支持触发路由事件。 是否有可能在 XAML 中混合路由事件和条件这两个概念?
Does WPF support using a triggers that respond to routed events but only given a condition is met?
For example, WPF supports triggering on routed events through Event Triggers.
ie:
<Button>
<Button.Triggers>
<EventTrigger RoutedEvent="Click">
...
</..
</..
</..
However I am looking for the trigger to go off only given a certain condition is met. Normally you use MultiTriggers for meeting multiple conditions. ie:
<Button>
<Button.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="..." Value="..."/>
<Condition Binding="..." Value="..."/>
</..
</..
</..
</..
However neither the MultiTrigger or MultiDataTrigger seem to support triggering on routed events. Is it even possible to mix these two concepts of routed events and conditions in XAML?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为是这样。 无论如何,这不是你思考的方式。
当多个属性同时具有匹配值时,
MultiTrigger
和MultiDataTrigger
将被触发。 这是很容易发生的事情,因为它是基于状态的。 它基于至少在一段时间内保持不变的价值观。另一方面,事件发生然后就消失了。 当两个多重事件不同时发生时,您如何反应?
您必须使用
EventTrigger
(可能在 set-enter/set-leave 对中)来设置某些属性的状态(附加属性在这里听起来不错),然后创建一个MultiTrigger
查看这些属性。I don't think it is. Not the way you're thinking about it, anyway.
The
MultiTrigger
andMultiDataTrigger
are triggered when multiple properties have the matching values at the same time. This is something that can easily happen because it is based on state. It's based on values that stay the same, at least for a while.Events on the other hand, happen and then are gone. How could you react two multiple events, when they not occurring at the same moment?
You would have to use your
EventTrigger
s -- perhaps in set-enter/set-leave pairs -- to set the state of certain properties (attached properties sound good here), and then create aMultiTrigger
that looked at those properties.