Question

I have a Grid with some child windows. Some of these children have a MultiBinding with a complicated converter. Now, if I hide the grid (Collapsed or Hidden) the converters are still being called. Why?!

When I hide an UI element I expect the renderer to completely skip its visual tree. More specifically, I want my converters not to be called when they are operating in a "hidden" context! Ideas?

Was it helpful?

Solution

Even when an element's Visibility property is Collapsed or Hidden it remains a part of the logical tree and therefore it is perfectly normal that the converters continue to work while the element is not visible.

One simple solution to disable value conversion while the element is Collapsed or Hidden is to use the ConverterParameter Property, bind it to element's Visibility property and in the converter check if this property is set to Collapsed or Hidden and skip the conversion if it is...

There might be a more elegant solution but this should do the trick if no one thinks of a better approach short of removing the element from the logical tree altogether...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top