Get ContentPresenter/ItemsPresenter from control

3.4k views Asked by At

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?

1

There are 1 answers

0
Colin Smith On BEST ANSWER

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: