WPF:在 DependencyProperty.UnsetValue 上触发

发布于 2024-08-28 10:25:18 字数 229 浏览 2 评论 0原文

在回答这个问题时,做出了以下声明

“理论上可能会......触发 {x:Static DependencyProperty.UnsetValue},这会更干净,但这在实践中似乎不起作用。”

有人有幸做到这一点吗?

in an answer to this question the following statement was made

"In theory it might be possible to .... trigger on {x:Static DependencyProperty.UnsetValue}, which would be much cleaner, but this doesn't appear to work in practice."

Has anybody had any luck in doing this?

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

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

发布评论

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

评论(1

无言温柔 2024-09-04 10:25:18

失败的 Binding 将返回 null(或后备值),这与 UnsetValue 不同。

itowlson 给您的答案可能是您能得到的最好的答案。在这种特定情况下,您也许可以使用:

<DataTrigger Binding="{Binding Hibble, FallbackValue={x:Static DependencyProperty.UnsetValue}}" Value="{x:Static DependencyProperty.UnsetValue}">
  <Setter Property="Background" Value="Red" />
</DataTrigger>

这实际上是相同的。

(您可能想看看这个

A failing Binding will return null (or the fallbackvalue), which is different from an UnsetValue.

the answer itowlson gave you is probably the best you will get. In this specific case, you might be able to use:

<DataTrigger Binding="{Binding Hibble, FallbackValue={x:Static DependencyProperty.UnsetValue}}" Value="{x:Static DependencyProperty.UnsetValue}">
  <Setter Property="Background" Value="Red" />
</DataTrigger>

which is practically the same.

(you might want to take a look into this)

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