Question

I have an wpf application that use the MVVM with a datagrid. I set the selectedIndex property in the viewModel, but the SelectedItems property is empty. Shouldn't it have the selected the selected item?

Was it helpful?

Solution

Not necessarily.

One way of doing this is to set SelectedItem property in the datagrid xaml to a property on your view model which implements INotifyPropertyChanged. Then set the xaml binding mode to two way.

Then if you click on a selected item it will trigger a change from the xaml binding to update the value in the view model

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top