简体   繁体   English

带有自定义下拉宽度的WPF ComboBox

[英]WPF ComboBox with custom dropdown width

How can I extend width of dropdown of a combo, like Run dialog: 如何扩展组合下拉列表的宽度,如“运行”对话框:

在此输入图像描述

Popup is a part of ComboBox template ("PART_Popup"). Popup是ComboBox模板(“PART_Popup”)的一部分。 Add a Style for Popup to combobox Resources and set appropriate width there. Popup样式添加到组合框资源并在那里设置适当的宽度。

<ComboBox>
    <ComboBox.Resources>
        <Style TargetType="Popup">
            <Setter Property="Width" Value="1000"/>
        </Style>
    </ComboBox.Resources>
</ComboBox>

note also that there is a binding for Popup.MinWidth in template so you can't make it too small. 另请注意,模板中的Popup.MinWidth存在绑定,因此您无法将其设置得太小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM