WPF中的多行组合框 [英] Multiline Combobox in WPF

查看:310
本文介绍了WPF中的多行组合框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找到一个用于WPF的多行用户可编辑组合框的示例。我们已经尝试了各种各样的事情与自定义模板,但不能使它的工作。我们试图解决的具体问题是在下拉列表中显示地址列表,用户可以在其中同时键入新列表。

I'm trying to find an example of a multi line user editable combobox for WPF. We've tried various things with a custom template but can't make it work. The specific problem we're trying to solve is displaying a list of addresses in a drop down where the user can type in new ones at the same time. Typing into a combobox is no problem.. multi line is killing us though.

推荐答案

如果我们想在ComboBox中显示Textbox,我们可以覆盖ComboBox的ItemTemplate。为了显示多行文本,我们可以为TextBox设置AcceptReturn =True。

If we want show Textbox in ComboBox we can override the ItemTemplate of ComboBox. And to display multiline text we can set AcceptReturn="True" for TextBox.

    <ComboBox Width="250" Height="30"  >
        <ComboBox.ItemTemplate>
            <DataTemplate>
                <TextBox AcceptsReturn="True" Width="200" Height="100"/>
            </DataTemplate>
        </ComboBox.ItemTemplate>
    </ComboBox> 

这是你需要的还是我缺少的东西?

Is this what you need or am I missing something?

这篇关于WPF中的多行组合框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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