(X) Hide this
    • Login
    • Join
      • Say No Bots Generate New Image
        By clicking 'Register' you accept the terms of use .
        Login with Facebook

Handling DataGrid.SelectedItems in an MVVM-friendly manner

(0 votes)
0 comments   /   posted by Silverlight Show on May 20, 2010
Tags:   datagrid , mvvm , laurent-bugnion
If you are wondering if there is an MVVM-friendly way to get a DataGrid’s SelectedItems into the ViewModel, read this blog post of Laurent Bugnion and find out the answer.

The issue there is as old as the DataGrid (that’s not very old but still): SelectedItem (singular) is a DependencyProperty and can be databound to a property in the ViewModel. SelectedItems (plural) is not a DependencyProperty.

Thankfully the answer is very simple: Use EventToCommand to call a Command in the ViewModel, and pass the SelectedItems collection as parameter.


Comments

No comments

Add Comment

Login to comment:
  *      *       
Login with Facebook

Our News on Twitter