WPF ComboBox 弹出位置:底部并与右边缘对齐 [英] WPF ComboBox popup placement : Bottom and aligned to the right edge

查看:18
本文介绍了WPF ComboBox 弹出位置:底部并与右边缘对齐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个具有非标准下拉对齐方式的 ComboBox.基本上,我希望下拉菜单位于 ComboBox 下方,但与 ComboBox 的右边缘对齐,而不是左边缘.

I'm trying to create a ComboBox with a non-standard dropdown alignment. Basically, I want the dropdown to be below the ComboBox, but aligned with the right edge of the ComboBox instead of the left edge.

使用 PlacementMode="Bottom" 的普通 ComboBox 是什么样子:

What a normal ComboBox looks like, using PlacementMode="Bottom":

我想要的:

我尝试在我的 ComboBox 的模板中使用 Popup.PlacementMode 属性,但似乎没有一个可能的值符合我的要求.有没有一种简单的方法可以做到这一点,最好是在纯 XAML 中?

I tried to play with the Popup.PlacementMode property in the template of my ComboBox, but none of the possible values seem to do what I want. Is there a simple way to do it, preferably in pure XAML?

推荐答案

当我打开 Expression Blend 时,我在几秒钟内就想出了解决方案:

When I opened Expression Blend, I have come up with the solution within a few seconds:

<Popup Placement="Left" VerticalOffset="{TemplateBinding ActualHeight}" 
       HorizontalOffset="{TemplateBinding ActualWidth}"

有时这个应用程序比手工编写 xaml 更有用,但不是那么频繁.

Sometimes this application is more useful than writing xaml by hands, but not so often.

这篇关于WPF ComboBox 弹出位置:底部并与右边缘对齐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆