tags:

views:

63

answers:

1

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 .

Thanks in advance for your help

A: 

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

Wouter Janssens - Xelos bvba