sflistview

Hi,

How to make selected item null in view model xamarin? I am makeing the selected item null but it not supported.
     private void GetPopularDestinationInfo(ref HotelBannerImageModel selectedItem, HotelBannerImageModel value)
        {
           
               
                if (CrossConnectivity.Current.IsConnected)
                {
             

                        Application.Current.MainPage.Navigation.PushAsync(new HotelListingPage());
                    
                }
                else
                {
                    if(App.Language=="en")
                    {
                        CrossToastPopUp.Current.ShowToastMessage(Constant.ErrorMessage);
                    }
                    else
                    {
                        CrossToastPopUp.Current.ShowToastMessage(Constant.ErrorMessage_ar);
                    }
             
                }
                selectedItem = null;
                this.RaiseEvent(nameof(SelectedItem));

            }

Thanks,

Yogita

2 Replies

CS Chandrasekar Sampathkumar Syncfusion Team May 8, 2020 05:00 PM UTC

Hi Yogita, 
Thank you for using Syncfusion products. 
We have checked the reported query “After setting null to binded property of ListView’s SelectedItem, it is not removed after navigating back” from our end. We like to let you know that we can replicate the issue on our side. We will check the issue with our source and update you further details on or before 12th May, 2020. We appreciate your patience until then. 
Regards, 
Chandrasekar Sampathkumar


CS Chandrasekar Sampathkumar Syncfusion Team May 12, 2020 11:02 AM UTC

Hi Yogita, 
Thank you for your patience. 
We would like to let you know that, setting null to ListView SelectedItem in TapCommand/ItemTapped is not recommended. As per implementation ListView SelectedItem will be set only after TapCommand/ItemTapped is executed, it is the behaviour of SfListView. You can achieve your requirement by using SelectionChanged event.  
We have prepared a sample based on the information provided and you can download the same using the following link, 
Sample Link: SfListViewSample 
Please check the attached sample and let us know if you are still facing the same issue? If yes, please modify our sample and revert us back or share the following details which would be helpful for us to check on it and provide the solution at the earliest.  
                Xamarin.Forms version and Syncfusion version used in your application. 
                Specific platform the reported issue reproduced. 
                Replication procedure to reproduce the issue. 
                ListView xaml page 
                GetPopularDestinationInfo’s Caller method definition 
Regards, 
Chandrasekar Sampathkumar 


Loader.
Up arrow icon