使用 WPF 转换器将 xpath 节点存在转换为可见/隐藏/折叠

发布于 2024-11-01 17:38:29 字数 240 浏览 7 评论 0原文

我已经成功地使用转换器将 WPF 中的布尔值转换为适当的属性,例如隐藏/折叠/可见以隐藏和显示控件。

我想使用 xpath 节点的存在来实现同样的事情 - 您在 XSLT 中测试的路径类型,例如:

如果节点存在,我希望转换器输出“可见”,如果不存在“隐藏”或“折叠”。

有人有什么想法吗?

I've been successfully using Converters to convert boolean values in WPF to an appropriate property e.g. Hidden/Collapsed/Visible for hiding and showing a control.

I'd like to achieve the same thing using the existence of an xpath node- the sort of path you'd test for in XSLT with something like:

<xsl:if test="/SomeNode/Exists"></xsl:if>

If the node exists, I want the converter to output "Visible" and if not "Hidden" or "Collapsed".

Anyone have any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

述情 2024-11-08 17:38:29

创建一个转换器,它将 XPath 查询作为 转换器参数

更多信息。

我认为我们无法提供更多 信息除了为您编写代码之外,还可以做其他事情:)

Create a converter, which will take the XPath query as ConverterParameter.

Some more info.

I don't think there is much more we can do aside from writing the code for you :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文