2017-03-04 31 views
2

由於MSDN saysTargetNullValue爲什麼TargetNullValue不能在x中使用:綁定?

Specifies a value to display when the source value resolves but is explicitly null.

隨着老綁定這樣的事情是可能的,並且工作:

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

但它不可能與x:Bind - 如果我們寫:

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

我們可能會得到錯誤:

TargetNullValue cannot be applied on 'Visibility' because its type 'Visibility' is not nullable.

這對我來說沒有多大意義 - 爲什麼?

+0

你必須處理的轉換器中的空值。 –

+0

@TóthTibor是的,處理它與轉換器是我已經做了什麼,它只是使* TargetNullValue *無用,因爲你不能使用它,當它應該是明顯可能的。 – Romasz

回答

1

Which for me doesn't make much sense - why is that?

按照documentation{x:Bind}缺少一些的{Binding}特點」,顯然,這是其中之一。

顯然TargetNullValue不能指定爲類型的目標屬性。

但是你可以很容易地在你的轉換器中處理這個問題,所以它應該是一個問題。

,如果你想你總是可以在UserVoice的提起這事:https://wpdev.uservoice.com/forums/110705-universal-windows-platform

+0

這就是我所害怕的,儘管它並沒有改變它對我沒有意義的事實。不過,我[發佈在UserVoice上](https://wpdev.uservoice.com/forums/110705-universal-windows-platform/suggestions/18521620-remove-type-check-from-x-bind-targetnullvalue)。 – Romasz

相關問題