检索列表框多个选定项 [英] Retrieve ListBox Multiple Selected Items

查看:57
本文介绍了检索列表框多个选定项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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.

推荐答案

我所知道的最好方法是在这篇文章中写到的:

Best way I know is written about in this post:

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


这篇关于检索列表框多个选定项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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