We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

SelectedItems TwoWay Binding not working

Thread ID:





150272 Dec 30,2019 10:53 AM UTC Jan 7,2020 07:09 AM UTC WPF 5
Tags: SfDataGrid
Helmut Wahrmann
Asked On December 30, 2019 10:53 AM UTC


i have downloaded your sample for MVVM implementation of SelectedItems in SfDatagrid from here: https://help.syncfusion.com/wpf/datagrid/mvvm

When running the sample, the items which are selected in the Constructor of the Viewmodel are shown as selected in the Grid.
However, if i select additional rows in the grid, the SelectedItems property setter gets never called.

could you please confirm  if this is a bug?



Susmitha Sundar [Syncfusion]
Replied On December 31, 2019 12:27 PM UTC

Hi Helmut,   
Thank you for using Syncfusion controls.   
We have checked the reported issue in our sample(https://help.syncfusion.com/wpf/datagrid/mvvm#datagrid-selecteditem-binding), and we are unable to replicate the issue from our end. SelectedItems setter property called for every selection. We have prepared a video for your reference, 
We have tested with Syncfusion version   
Please check the above link and revert us if you still facing the same issue? If yes, please modify the sample based on your scenario. It will be helpful for us to check on it and provide you the solution at the earliest.     
Susmitha S   

Helmut Wahrmann
Replied On January 3, 2020 09:47 AM UTC

Hi Susmitha,

i was referring to SelectedItems  and not SelectedItem.

btw, if you use the SelectedItem sample and you select multiple rows, the SelectedItem only contains the first selected item and not the row, which you just selected.



Susmitha Sundar [Syncfusion]
Replied On January 6, 2020 02:17 PM UTC

Hi Helmut, 
Thank you for your update. 
In SfDataGrid, SelectedItems property is collection type. So, if you click any row, SelectedItems collectionchanged event called. Please refer the below image, 
Please check the sample and let us know if you need further assistance on this. 
Susmitha S 

Helmut Wahrmann
Replied On January 6, 2020 06:53 PM UTC

Hi Susmitha,

so you created some code behind.
I was referring to your MVVM samples and here the "set" on line 21 in PersonModel.cs is never called, when you select something.



Susmitha Sundar [Syncfusion]
Replied On January 7, 2020 07:09 AM UTC

Hi Helmut,   
Thank you for your update.   
In SfDataGrid, SelectedItems is ObseravableCollection of object. If you want to call its setter, you need to assign the collection to that property. Please refer the below code snippet  
ObservableCollection<object> selectedItemsCollection = newObservableCollection<object>();   
PersonModel viewModel;   
public MainWindow()   
    viewModel = this.DataContext as PersonModel;   
    this.dataGrid.SelectedItems.CollectionChanged += SelectedItems_CollectionChanged;   
private void Button1_Click(object sender, RoutedEventArgs e)   
     viewModel.SelectedItems = selectedItemsCollection;   
In our sample, when you select the items, these items are added to that collection, so its collection changed called. It’s a difference between assign and add the items. Please refer the below sample,   
Please let us know if you need further assistance on this.   
Susmitha S   


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon