我有一个 ContentControl 从左到右组成 Button ,分区和 ComboBox . 我想要 组合框 下拉以与控件的左侧对齐,而不是与控件的左侧对齐。 组合框 . 我收到了一个代码中的方法,但我想知道它是否可以在XAML中完成。
ContentControl
Button
ComboBox
组合框
这给了我控件的名称:
ToolTip="{Binding Path=Name, RelativeSource={RelativeSource FindAncestor, AncestorLevel=2, AncestorType={x:Type Control}}}"
但我想引用控件:
Placement="Bottom" PlacementTarget="{Binding ElementName=[Fancy-Smancy xaml goes here!]}"
有什么想法吗?
如果指定 AncestorLevel 以及 AncestorType :
AncestorLevel
AncestorType
Placement="Bottom" PlacementTarget="{Binding RelativeSource={RelativeSource FindAncestor, AncestorLevel=2, AncestorType={x:Type Grid}}}"