Silverlight中的ComboBox [英] ComboBox in Silverlight
问题描述
如何清除组合框中的选定值而不删除列表中的任何值.
How to clear a selected value in combo box without deleting any value in the list.
推荐答案
不确定要这样做的内容.
据我了解,您想重置下拉列表值.
您可以使用
Not sure what you want to so.
According to my understanding you want to reset dropdown values.
You can use
DropDownList1.SelectedIndex=-1;
尝试一下
如果认为:
try this
if in view:
ComboBox1.SelectedIndex = -1
或您想在Viewmodel中使用它,
然后为所选项目设置属性.并将其设置为null:
例如:
or dou you want it in viewmodel,
then Have a property for selected item. and set it to null:
For eg:
public List<gender> GenderList
{get;set;}
//包括通知属性已更改的属性..以上只是大纲
然后拥有一个属性
//include notify property changed for that property..the above one is just outline
Then have a property
Public Gender SelectedGender
{get;set;}
将Itemsource绑定到GenderList属性,并将Selectedvalue属性绑定到SelectedGender.
每当您想清除选择Set SelectedGender = null时.因为那里有Notifyproperty更改的元素,它将清除选择
Bind Itemsource to GenderList property and Selectedvalue property to SelectedGender.
Whenever You want to clear the selection Set SelectedGender =null. SInce Notifyproperty changed element is there, it will clear the selection
这篇关于Silverlight中的ComboBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!