I'm using a DevExpress LayoutGroup
, which constructs multiple children I have no influence on. The LayoutGroup
has an IsCollapsible
property, which, when true, adds a button to the group's header and the functionality of collapsing/expanding the group's content.
The constructed visual tree looks like this:
[LayoutControl]
CollapsibleNavigationGroup [LayoutGroup]
[GroupBox]
[Container]
BorderElement [Border]
[LayoutControl]
TitleElement [Container]
TitleContent [LayoutControl]
This usually only works when clicking the button itself but I extended the functionality to clicking the header. Now, if the GroupBox
is collapsible I want the cursor to change to a hand when hovering above the header, so I did this in its template:
<dxlc:LayoutControl x:Name="TitleContent"
Cursor="{Binding IsCollapsible, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type dxlc:LayoutGroup}}, Converter={StaticResource BoolToCursorConverter}}">
However, LayoutControl
is derived from LayoutGroup
and thus FindAncestor does not actually find my CollapsibleNavigationGroup but the element's grand-parent, the nameless LayoutControl
. Now I wonder, is there any way to tell the relative source binding to actually look for this exact type and ignore any derived types?
Now I wonder, is there any way to tell the relative source binding to actually look for this exact type and ignore any derived types?
No, there isn't. But you can set the AncestorLevel
property to 2
to skip the first ancestor of the type specified by the AncestorType
property, e.g.:
<dxlc:LayoutControl ... Cursor="{Binding IsCollapsible, RelativeSource={RelativeSource Mode=FindAncestor,
AncestorType={x:Type dxlc:LayoutGroup},
AncestorLevel=2}, Converter={StaticResource BoolToCursorConverter}}">