问题描述
我有一个ListBox,其中有一个绑定到itemsSource的项目列表.列表框选择模式设置为扩展,以便用户可以选择多个项目.由于列表框仅具有SelectedItem属性,因此我可以将其绑定到ViewModel中的属性以仅获取一个 选定的项目.
I have a ListBox that has a list of items binded to a itemsSource. Listbox selection mode is set to extended so that user can selected multiple items. As Listbox has only SelectedItem property which I can a bind to a property in ViewModel to get only one selected item.
由于此控件有多个选择,因此我需要多个选择的项目.因此,如何利用MVVM方法从列表框中获取选定的项目.
As this control has multiple selections, I want multiple selected items. So, how can I can make use of MVVM approach to get the selected items from Listbox.
我不想使用交互触发器方法.还有什么其他方法可以从ListBox中获取选定的项目.
I don't want to use interaction triggers approach. Is there any other way I can get the selected items from ListBox.
推荐答案
https://social.msdn.microsoft.com/Forums/vstudio/zh-CN/99710d01-e064-4053-ac0a-8a46ab6cf761/multiple-selection-with-listbox-in-mvvm?forum=wpf
https://social.msdn.microsoft.com/Forums/vstudio/en-US/99710d01-e064-4053-ac0a-8a46ab6cf761/multiple-selection-with-listbox-in-mvvm?forum=wpf
这篇关于检索列表框多个选定项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!