Question

I need a way to access the ContentPresenter/ItemsPresenter from a control if it does exist.

I can't figure out how to easily do this with VisualTreeHelper.

Will I need to recursively search all children?

Was it helpful?

Solution

Yes you need to recurse through the Visual tree....FindVisualChild can do that for you...if you supply it with an instance to the control.

ContentPresenter myContentPresenter = FindVisualChild(dependencyobject);

Some links:

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