This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 months ago.
Improve this questionI 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?
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}}}"
精彩评论