没有下拉按钮的 WPF ComboBox [英] WPF ComboBox without drop-down button

查看:19
本文介绍了没有下拉按钮的 WPF ComboBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个 ComboBox,它没有下拉按钮,但当我点击 ComboBox 中的文本时仍然可以打开.这可以用 WPF ComboBox 实现吗?

I want a ComboBox which has no drop-down button but can still be opened when I click on the text in the ComboBox. Is this possible with a WPF ComboBox?

推荐答案

这是可能的,但您需要重新设计它以达到完美.您可以通过如下覆盖系统参数来获得大部分方法:

It's possible, but you would need to retemplate it to achieve perfection. You can get most of the way there by overriding a system parameter as follows:

<ComboBox xmlns:sys="clr-namespace:System;assembly=mscorlib">
    <ComboBox.Resources>
        <sys:Double x:Key="{x:Static SystemParameters.VerticalScrollBarWidthKey}">0</sys:Double>
    </ComboBox.Resources>
    <ComboBoxItem>One</ComboBoxItem>
    <ComboBoxItem>Two</ComboBoxItem>
    <ComboBoxItem>Three</ComboBoxItem>
</ComboBox>

但是,它并不完美,因为焦点矩形仍然假定存在下拉按钮.

However, it isn't perfect because the focus rectangle still assumes there is a drop-down button present.

这篇关于没有下拉按钮的 WPF ComboBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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