是否有任何本机 WPF 多选组合框可用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/508506/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 20:01:08  来源:igfitidea点击:

Is there any native WPF Multiselect combobox available?

wpfcomboboxwpf-controlsmulti-select

提问by Amit Sharma

Even a 3rd party one will do.

即使是第 3 方也可以。

Thanks

谢谢

采纳答案by Jobi Joy

There is no native multiselect combobox in WPF. Please check my blog for a simple hack using expression blend to achieve a multi selection on combobox. http://jobijoy.blogspot.com/2009/02/simple-multiselect-combobox-using.htmlThe idea is to utilize the Multi-Selection feature of ListBox in to ComboBox by editing the control template.

WPF 中没有本机多选组合框。请查看我的博客,了解使用表达式混合在组合框上实现多选的简单技巧。 http://jobijoy.blogspot.com/2009/02/simple-multiselect-combobox-using.html这个想法是通过编辑控件模板将ListBox 的Multi-Selection 特性利用到ComboBox 中。

But for accessing the selected items you might need to use the bellow line in the code.

但是要访问所选项目,您可能需要使用代码中的波纹管。

((ListBox)cmbBox.Template.FindName("lstBox",cmbBox)).SelectedItems

Where cmbBoxis your combobox and lstBoxis the ListBox inside the controltemaplate.

其中cmbBox是您的组合框,lstBox是控件模板内的列表框。

回答by Adrian

I'm not sure how a ComboBoxwould display data in this fashion, as it is designed as a single-selection Control.

我不确定 aComboBox将如何以这种方式显示数据,因为它被设计为单选控件。

Maybe you are looking for something like a ListBoxor ListViewwith a SelectionModeof Multipleor Extended?

也许你正在寻找的东西像ListBoxListViewSelectionModeMultiple还是Extended

<ListBox SelectionMode="Multiple" />

<ListBox SelectionMode="Extended" />

回答by Jas

I used an expander and filled the expander's header with the selection and the content with a list box. The list box is binded to a collection. Whenever user make a selection, I update the header to show what user has selected.

我使用了一个扩展器,并用选择和一个列表框的内容填充了扩展器的标题。列表框绑定到一个集合。每当用户进行选择时,我都会更新标题以显示用户选择的内容。

回答by Shakti Prakash Singh

I found this useful information from Codeproject - ComboBoxMultiSelect

我从 Codeproject - ComboBoxMultiSelect 中找到了这个有用的信息

I haven't tried it myself as of yet, but would let know about my experience.

我自己还没有尝试过,但会告诉我我的经验。

回答by Dave

Although I am yet to get this to work, this looks like what I need and similar to what you are looking for:Just Guy's Blog

虽然我还没有让它工作,但这看起来像我需要的并且与你正在寻找的相似:Just Guy 的博客

回答by Peter Huber

Another CodeProject with detailed explanations how to create a ComboBox with multiple selectable Checkboxes: Multi Select ComboBox in WPF

另一个 CodeProject 详细解释了如何创建具有多个可选复选框的组合框: WPF 中的多选组合框