WPF | VisualTreeHelper.GetChildrenCount(this) on collapsed parent

860 views Asked by At

I have a "huge" Control where ~50% of it is collapsed. You can switch by a property to hide the visible part and show the collapsed one.

Now when the Control is loaded, I try to find all FooControls in the visible and collapsed part of the control. The problem is, that only the FooControls of the visible part are found. If I debug the code, I can see FooControls in the parent Control of the collapsed part.

Can you give me a hint how to solve this problem?

I need to change a Property of FooControl after it's loaded. I also need to be dynamic, because it comes with a behavior.

1

There are 1 answers

0
JohnChris On

The answer is simply to use Logical Tree Helper , Visual Tree helper finds all the objects that are visible, while logical can see all controls made, you might have to refine your code a bit but as you haven't given any more information, I can't help.