作为MSDN says,TargetNullValue:


  指定当源值解析但显式为null时显示的值。


在旧的Binding中,这样的事情是可行且可行的:

<Grid Visibility="{Binding Something, Converter={StaticResource myconv}, TargetNullValue='Collapsed'}">


但是x:Bind是不可能的-如果我们这样写:

<Grid Visibility="{x:Bind Something, Converter={StaticResource myconv}, TargetNullValue='Collapsed'}">


我们可能会得到错误:


  无法将TargetNullValue应用于“可见性”,因为其类型“可见性”不可为空。


这对我来说没有多大意义-为什么呢?

最佳答案

这对我来说没有多大意义-为什么呢?


根据documentation的说法,“ {x:Bind}缺少{Binding}的某些功能”,显然这是其中之一。

显然,不能为值类型目标属性指定TargetNullValue

但是您可以在转换器中轻松处理此问题,因此这应该是一个很大的问题。

如果您要执行以下操作,可以随时在UserVoice上提出:https://wpdev.uservoice.com/forums/110705-universal-windows-platform

10-01 23:09