0

我有一个ContentControl从左到右的 a Button,分区和 a ComboBox。我希望ComboBox下拉菜单与控件的左侧对齐,而不是ComboBox. 我收到了一个代码中的方法,但我想知道它是否可以在 xaml 中完成。

这给了我控件的名称:

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

但我想引用控件:

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

有什么想法吗?

4

1 回答 1

0

事实证明,如果您指定AncestorLevel和, RelativeSource 工作正常AncestorType

Placement="Bottom" 

PlacementTarget="{Binding RelativeSource={RelativeSource FindAncestor, AncestorLevel=2, AncestorType={x:Type Grid}}}"
于 2009-12-02T18:38:35.797 回答