Find visual parent before loaded event was called

401 Views Asked by At

Is it possible in WPF to find a visual parent of an object (UIElement) before the loaded event was triggered? If i search for a specific parent in the loaded event, every thing works fine. If i search for a specific parent in the constructor after LoadComponent, it does not work. Or do i have to use the logical tree?

I use the VisualTreeHelper for searching.

Thank you

1

There are 1 best solutions below

2
On BEST ANSWER

WPF only inserts the elements into the tree (logical or visual) after the constructor was called. So you cannot find the parent elements in the constructor.

It wouldn't make sense to insert something that does not exist yet into the tree.