TargetNullValue for visibility associated with boolean

I have a Grid , the Visibility property is tied to the logical property of some model using Converter :

 <Grid Visibility="{Binding ElementName=MyTreeView, Path=SelectedItem.MyBoolProperty, Converter={StaticResource boolToVisConverter}}"> <!-- child elements --> </Grid> 

It works great when an item is selected in my TreeView , but if nothing is selected or the TreeView empty, it will be visible by default. I need it to be hidden by default. I tried using TargetNullValue=Hidden , but it does not work. I think I just don’t understand how the TargetNullValue property should work in this situation.

Does anyone have any ideas how to get the functionality I'm looking for?

+4
source share
1 answer

I spent hours trying to figure it out. Then, of course, right after I posed the question, I get it using FallbackValue=Hidden in the Binding Grid property.

+7
source

All Articles