列表框的结算将selectedItem与MVVM(这势必对象的集合) [英] Clearing selecteditem of listbox (which is bound to collection of objects) with MVVM

查看:83
本文介绍了列表框的结算将selectedItem与MVVM(这势必对象的集合)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与Silverlight 4,我有绑定到对象列表列表列表框。

I have a listbox with silverlight 4. I have the list bound to a list of objects.

1。)SelectedValue属性绑定到当前所谓的视图模型的公共属性。如何清除的选择?我已经尝试设置当前的值设置为null。那么,这将清除但它也打破了有必然当前的属性的组合框编辑表单绑定的选择。这必将对Current.FirstName等文本框的工作确定后,但我设置当前对象为null的组合框不起作用。

1.) The SelectedValue property is bound to a public property of the viewmodel called Current. How do i clear the selection? I have tried setting the value of Current to null. Well, this clears the selection however it also breaks binding in the edit form which has a combobox bound to a property of 'Current'. Textboxes which are bound to Current.FirstName etc. are working ok however the comboboxes do not function after I set the Current object to null.

2)如何加载的形式没有被选中的第一个项目?

2.) how do i load the form without the first item being selected?

推荐答案

不知道,当它是固定的,但现在VoodooChild的回答工作在Silverlight 5的情况下,其他国家一道通过这项正在寻找。

Not sure when it was fixed but VoodooChild's answer works now in Silverlight 5. Passing this along in case others are looking.

yourCB.selectedIndex = -1;

这篇关于列表框的结算将selectedItem与MVVM(这势必对象的集合)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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