Get the unselected items from sfListView

Hello!  I have a program that contains an sfListView.  It has an event OnSelectionChanged that runs some code and changes the visuals of a cell when a cell is tapped.  It then marks the cell as selected.  I can then call all of the selected cells and place them into a List<T> by calling listView.SelectedItems.  Is there a good solution for getting the items that were NOT selected?  

3 Replies

DB Dinesh Babu Yadav Syncfusion Team July 19, 2017 01:39 PM UTC

Hi Tommy,   
   
Thank you for using Syncfusion Products.   
   
The reported requirement “Get unselected items in SfListView” can be achieved by a workaround in sample level. In the sample, you can filter the SelectedItems and unselected items from the underlying collection like below code example.   
   
Code Example[C#]:   
private void listView_SelectionChanged(object sender, ItemSelectionChangedEventArgs e)   
{   
  var unselecteditems = new List<Contacts>();   
  var selecteditems = new List<Contacts>();   
  for (int i = 0; i < viewModel.contactsinfo.Count; i++)   
  {   
    var item = viewModel.contactsinfo[i];   
    if (listView.SelectedItems.Contains(item))   
        selecteditems.Add(item);   
    else   
        unselecteditems.Add(item);   
  }   
}   
  
    
Please let us know if you require further assistance.   
   
Regards,   
Dinesh Babu Yadav   
 



PU pumaprog July 20, 2017 02:50 AM UTC

Thank you Dinesh!  This put me on the right path.



DB Dinesh Babu Yadav Syncfusion Team July 20, 2017 06:03 AM UTC

Hi Tommy, 
 
Thank you for your valuable feedback. 
 
Regards, 
Dinesh Babu Yadav 


Loader.
Up arrow icon