简体   繁体   English

如何在LISTBOX MVVM LIGHT上设置多个项目

[英]How to set multiple items on LISTBOX MVVM LIGHT

I'm using MVVM Light on an SL4 app. 我正在SL4应用程序上使用MVVM Light。 I would like to set the selected items on a listbox after it is databound. 我想在数据绑定后在列表框中设置所选项目。

I have no problem when there is one item to set, but I do not know how do do this when I have to set multiple items in the list. 当有一个项目要设置时,我没有问题,但是当我必须在列表中设置多个项目时,我不知道该怎么做。

Bind the IsSelected property of the ItemContainerStyle to a bool property on the view models that are bound to ItemsSource. 将ItemContainerStyle的IsSelected属性绑定到绑定到ItemsSource的视图模型上的bool属性。

You can then just set that property to true or false to select or deselect the item in the listbox. 然后,您可以将该属性设置为true或false来选择或取消选择列表框中的项目。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM