WPF Textblock TargetNullValue not working?

I have a wpf text block as shown below:

<TextBlock Text="{Binding [someViewModel].SomeVar.SomeSubVar.Name, 
                          TargetNullValue='-'}"/>

On my side of the viewmodel I will have my own logic, which in the end SomeVar.SomeSubVarwill be null.

If I want to show the default value for this TextBlock, I know that I can declare and initiate SomeVar.SomeSubVarand assign the default value to SomeVar.SomeSubVar.Name, but I would like to use instead TargetNullValue. Can I find out which part is wrong?

+4
source share
2 answers

FallbackValue http://msdn.microsoft.com/en-us/library/system.windows.data.bindingbase.fallbackvalue(v=vs.110).aspx TargetNullValue.

, TargetNullValue , [someViewModel].SomeVar.SomeSubVar.Name . "someViewModel", "SomeVar" "SomeSubVar" , "" , TargetNullValue .

+12

Binding TargetNullValue TextBlock, [somveViewModel].SomeVar.SomeSubVar.Name null. [somveViewModel].SomeVar.SomeSubVar.Name. null TargetNullValue.

. .

, : , .

+4

Source: https://habr.com/ru/post/1531087/


All Articles