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

sfListView SelectionChanged seems not firing

it seems that the selectionchanged event of my sfListview is not firing when I select items

I have attached a simplified sample of what I am doing.

My expected final goal has not been implemented in the sample, but I wanted to achieved is, after selecting the items, user will click on the submit button, the code will take the SfListView.SelectedItems put in a List and do further processing. 

Attachment: TestProject_c6cd955d.zip

1 Reply

CS Chandrasekar Sampathkumar Syncfusion Team February 3, 2020 01:16 PM UTC

Hi Benjamin, 

 Thank you for using Syncfusion products. 

 We have checked the reported query from our end. The mentioned issue occurs because SfCheckBox will take the focus so that SfListView's SelectionChanged event will not be fired. So you can use StateChanged event in SfCheckBox to achieve your requirement. Please refer the following code snippet for more reference, 

Xaml: 

<buttons:SfCheckBox Text="{Binding ContactName}"  

                                                        StateChanged="SfCheckBox_StateChanged" 

                                                        IsChecked="{Binding IsDone}"> 

buttons:SfCheckBox> 

 

C#: 

 

   private void SfCheckBox_StateChanged(object sender, Syncfusion.XForms.Buttons.StateChangedEventArgs e) 

        { 

            var checkBox = (sender as SfCheckBox).BindingContext as Contacts; 

            lblSelectedAssignee.Text += "selectionChanged|"; 

            ObservableCollection <object> items = new ObservableCollection<object>(); 

            if (e.IsChecked == true) 

            { 

                listAssignee.SelectedItems.Add(checkBox); 

                items = listAssignee.SelectedItems; 

            } 

            else if(e.IsChecked == false) 

            { 

                listAssignee.SelectedItems.Remove(checkBox); 

                items = listAssignee.SelectedItems; 

            } 

            for (int i = 0; items.Count > ii++) 

            { 

                var item = items[i] as Contacts; 

                item.IsDone = true; 

                selectAssignee += "" + item.ContactName + "|"; 

                if (i == items.Count - 1) 

                    lblSelectedAssignee.Text += lblSelectedAssignee.Text + item.ContactName + " . "; 

                else 

                    lblSelectedAssignee.Text += lblSelectedAssignee.Text + item.ContactName + " , "; 

            } 

            entryAssignee.Text = selectAssignee; 

        } 


We have modified the sample based on your requirement and we have attached the sample in the following link,
 

Sample Link : SfListViewSample 

Please check the sample and let us know if you still facing the same issue? If not, please modify our sample and revert us back. It will be helpful for us to check on it and provide you the solution at the earliest.  

Regards, 

Chandrasekar Sampathkumar 


Loader.
Live Chat Icon For mobile
Up arrow icon