开发者

Using WPF combobox ,datatable, mvvm

I have very simple scenario ,

I have WPF Combo , i am using MVVM , i am assigning a datatable as a datasource to this WPF combo, i am able to assign , able to view data but not sure how to get the selecteditem in my viewmodel layer, i dont want to pollute my UI codebehind .

Than开发者_Python百科ks in advance for your help


You can create a SelectedDataRow property on your ViewModel and bind the SelectedItem of your Combo to that property on your ViewModel.

This property will be updated when your selected item of the combobox changes and as an extra you can change the selection of your combobox from the ViewModel by changing the SelectedDataRow property.

Make sure that your property raises the PropertyChanged event of your ViewModel

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜