WPF:DependencyProperty.UnsetValue上的触发器 [英] WPF: Trigger on DependencyProperty.UnsetValue

查看:516
本文介绍了WPF:DependencyProperty.UnsetValue上的触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题的答案中,提出了以下声明

in an answer to this question the following statement was made

理论上来说,可能会触发{x:Static DependencyProperty.UnsetValue},这将会更清晰,但这并不会出现在实践中工作。

"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?

推荐答案

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

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

itowlson给你的答案可能是你最好的得到。在这种具体情况下,您可能可以使用:

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>

这几乎是一样的。

(您可能需要查看

这篇关于WPF:DependencyProperty.UnsetValue上的触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆