
Let us start with the detail of the View Model and the View so that you can have clear understanding of what is happening in the example code.
View Model :
First I will discuss the important area of the view model, Here you can see that OnSelectionChanged command takes the object type parameter which is first converted to the IList type in the first statement. Then in the next statement I have set empty string to the SelectedItemIds property which is of type string to display the SelectedItems Ids only below the buttons in the View. In the next statement I have place foreach loop too loop through the selected item of the Data Grid. As the Item Source of the data grid items are of type Customer type. So I have used same type in the foreach loop and then add the ids in the SelectedItemIds and place comma (,) sign between the ids if user has selected more then one item.
Read more: Asim Sajjad
QR: