WPF ComboBox DropDown using PlacementTarget

1.4k Views Asked by At

I have a ContentControl comprised from left to right of a Button, partition and a ComboBox. I want the ComboBox dropdown to line up with the left side of the control as opposed to the left side of the ComboBox. I received a method in code but I was wondering whether if it could be accomplished in xaml.

This gives me the name of the control:

ToolTip="{Binding Path=Name, RelativeSource={RelativeSource FindAncestor, AncestorLevel=2, AncestorType={x:Type Control}}}"

But I would like a reference to the control:

Placement="Bottom" PlacementTarget="{Binding ElementName=[Fancy-Smancy xaml goes here!]}"

Any thoughts?

1

There are 1 best solutions below

0
On BEST ANSWER

Turns out that a RelativeSource works fine if you specify the AncestorLevel and the AncestorType :

Placement="Bottom" 

PlacementTarget="{Binding RelativeSource={RelativeSource FindAncestor, AncestorLevel=2, AncestorType={x:Type Grid}}}"