开发者

WPF ComboBox DropDown using PlacementTarget [closed]

开发者 https://www.devze.com 2022-12-12 20:13 出处:网络
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.

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 question

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?


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}}}"
0

精彩评论

暂无评论...
验证码 换一张
取 消