![](/img/trans.png)
[英]Adding item in empty observable collection which bind to combobox lead to auto select this item in combobox, but selected value is still null
[英]Adding a null or empty value to a combobox at the top of the list
我希望我的组合框的第一个值为空,以便用户可以清除他们之前的选择。 组合框绑定到 ViewModel 中的实体。 那么如何添加第一个值。 我可以使用combobox.inert(0, new Entity)
,但这是正确的方法吗?
这是出于搜索目的:默认情况下,combobox 没有选择,搜索将找到所有内容。 如果他们 select 一个项目,则搜索被过滤。
由于您的 ViewModel 负责准备要由 View 显示的数据,因此 ViewModel 应在集合的开头添加空元素,然后将其绑定到 combobox。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.