Binding ComboBox.SelectedItem in Silverlight

泄露秘密 提交于 2019-11-29 11:08:27

Try this:

 <ComboBox ItemsSource="{Binding Path=Thing.Stuff}"                
      SelectedItem="{Binding Path=Thing.SelectedStuff, Mode=TwoWay}">

SelectedItem does not like to be bound OneWay. I haven't had a chance to try it out in Silverlight 2 but in Silverlight 3 you will even get the yellow triangle of death if you don't use TwoWay binding.

xcv

Of course the binding has to be TwoWay. But setting a ItemsSource to a control doesn't means that the DataContext (where SelectedItem variable should point to) is set. Ensure that combo's DataContext is well set. (in my case, to Page. As selectedStuff is a Page property.

cmbStuff.DataContext = Me '(from  Page.Load)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!