I have found the need to collapse a given WPF element or control when it is visually empty and I'm curious whether others have come across this and if so what type of solutions have worked.
My current case is one where I have a Border control that either will have a child element or not depending on various cases. When Border.Child is null or otherwise unset I would like to also set Border.Visibility to Collapsed. I've tried making a trigger to do this which seemed to be the most logical solution however it appears that Child is not a dependency property and so when I attempted this I got a runtime exception.
As a workaround for now I've bound to a different property in my DataContext which coupled with a ValueConverter gives me a resulting condition which I can use to achieve the desired result. I'm hoping though that somebody may be able to come up with some slick Attached Behavior or some other trick that may be able to simplify collapsing empty elements in WPF.