0

I have Silverlight MVVM project and can't get DataGrid SelectedItems from XAML code in ViewModel...

<gps:DataGrid
            ItemsSource="{Binding Nodes}"

            SelectedItems="{Binding Node, Mode=TwoWay}"

            Grid.Row="2"
            HeadersVisibility="None"
            HorizontalContentAlignment="Stretch">
            <gps:DataGrid.Columns>
               ...
            </gps:DataGrid.Columns>
        </gps:DataGrid>

I get an error "The property "SelectedItems" does not have an accessible setter" How can I get this property in ViewModel?

BurnOut
  • 111
  • 1
  • 7
  • I think, that would be **SelectedItem="{Binding Node, Mode=TwoWay}"** . Terms like _SelectedItems_ or (plurals of single selection) are generally a read only collection of one or more selectedItems. – Rohit Prakash Feb 10 '15 at 10:13
  • yeah, but I want to get multiple selected items, not only one selected item... I want to get only, don't need to set value from viewmodel – BurnOut Feb 10 '15 at 10:19
  • 1
    possible duplicate of [WPF Binding SelectedItems in MVVM](http://stackoverflow.com/questions/22868445/wpf-binding-selecteditems-in-mvvm) – Nahum Feb 10 '15 at 10:21
  • @BurnOut, Nahum answer will best suit your requirement in that case. – Rohit Prakash Feb 10 '15 at 10:22
  • Does this answer your question? [Bind to SelectedItems from DataGrid or ListBox in MVVM](https://stackoverflow.com/questions/9880589/bind-to-selecteditems-from-datagrid-or-listbox-in-mvvm) – StayOnTarget Jul 20 '20 at 16:58

0 Answers0