I have a style containing binds expression of the form
{Binding Path, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type MyType}}}
However, sometimes the DataContext in which this style operates is actually of type MyType. In this case, FindAncestor doesn't do what I want: it starts its search from the parent.
Is there any {Binding ...} incantation that checks the type of the current datacontext before continuing up the element hierarchy? I have other solutions specific to my project, but FindAncestor is so close...
RelativeSourcebindings do not look for DataContexts, they search the visual tree for UI elements. TheAncestorTypeshould be a control.To perform a
RelativeSourcebinding on the same control you can useRelativeSource Self