有条件的触发器WPF

编程入门 行业动态 更新时间:2024-10-28 08:18:04
本文介绍了有条件的触发器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

本文发布于:2023-11-06 04:54:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1562763.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:触发器   有条件   WPF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!