简体   繁体   English

在WPF中配置ListBox,这样我就可以在不保持CTRL键的情况下选择多个项目

[英]Configure ListBox in WPF so that I will be possible to select multiple items without holding CTRL key

I have a Listbox that allows user to select multiple items. 我有一个允许用户选择多个项目的列表框。 Normally user can do that by holding CTRL key and clicking the item he or she wants to select. 通常用户可以通过按住CTRL键并单击他或她想要选择的项来完成此操作。

Is it possible to configure this listbox so that the user will not have to hold the CTRL key when selecting items ? 是否可以配置此列表框,以便用户在选择项目时不必按住CTRL键? So that he or she will just click the item (without holding anything) and the item will be selected(diselected if it was selected previously) ? 这样他或她只需点击该项目(不保留任何东西),该项目将被选中(如果之前选择了该项目)?

Thank you 谢谢

Use 使用

SelectionMode="Multiple"

From the MSDN : 来自MSDN

The SelectionMode property determines how many items a user can select at one time. SelectionMode属性确定用户一次可以选择的项目数。 You can set the property to Single (the default), Multiple , or Extended . 您可以将属性设置为Single (默认值), MultipleExtended The following table described the behavior of these enumeration values. 下表描述了这些枚举值的行为。

Single The user can select only one item at a time. 单个用户一次只能选择一个项目。

Multiple The user can select multiple items without holding down a modifier key. 多个用户可以选择多个项目而无需按住修改键。

Extended The user can select multiple consecutive items while holding down the SHIFT key or non-consecutive items by holding down the CTRL key and clicking the items. 扩展用户可以通过按住CTRL键并单击项目,在按住SHIFT键或非连续项目的同时选择多个连续项目。

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

相关问题 如何在不按住Ctrl键的情况下在WPF DataGrid中选择多行? - How select multiple rows in WPF DataGrid without holding Ctrl Key? 如何在不使用C#按住CTRL键的情况下在UI网格中选择多行? - How to select multiple rows in a UI grid without holding CTRL key using C#? 树视图中的 WPF ListView 选择我需要在选择更改事件中获取所有选定的 ListView 项目(按住 CTRL 键时) - WPF ListView Selection inside a treeview I Need to get all the selected ListView Items(when Holding CTRL key) in selection changed event 多重选择列表框项目而不使用jQuery使用CTRL? - Multiple select listbox item without using CTRL using jquery? Select wpf 中列表框中的多个项目使用 c# - Select Multiple items in listbox in wpf using c# 如何在不按Ctrl键的情况下选择datagridview的多个单元格? - How do i select multiple cells of datagridview without pressing Ctrl key? 如何在Asp.Net中不按CTRL的情况下在列表框中选择多个项目? - How to multiple select item in ListBox without press CTRL in Asp.Net? 无法在列表框中选择多个项目 - Cannot select multiple items in Listbox 从列表框中选择多个项目 - Select multiple items from a listbox Select 默认情况下 ListBox 中有 2 个或更多项 WPF - Select by default 2 or more items in ListBox WPF
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM