views:

8

answers:

1

How does the XAML engine search for Binding.ElementName vs RelativeSource.AncestorType.

It would take a huge different when I am searching for a parent Window or Page (that x:Name was set in it), if the ElementName searches up (meaning starting from near current element up the tree levels children, then it's better to use the AncestorType since it won't search the siblings, just the ancestors. But if it (the ElementName) starts from to top of the visual tree and goes deeper and deeper, then of course I should get it by the ElementName property.

Bottom line: my question is whether the Binding.ElementName is search for the name from the top of the tree, or from the point of the binding upwards.

So please share me with your knowledge.

A: 

FYI: As far as I found from my shallow research with .NET reflector, it seems that the ElementName search searches from the current element upwards, so it's better using RelativeSource and AncestorType (FindAncestor mode).
HTH

Shimmy