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
close icon

SelectionMode="SingleDeselect" doesnt work when navigating back to the page from another page

When navigating to a details page from a sfdatagrid selecteditem and coming back to this page as you know that sfdatagrid view selecteditem will remain. This is a default behaviour also xamarin.forms listview. 
Problem here is you can re-select the previously selecteditem If it was navigated back to this page. I thought that SingleDeselect Mode is perfect solution in this scenario. So I could click to "Deselect" and click again to "Reselect" but this doesnt work.

So my questions are is it intended to be like that or a bug? If either of them, now how can I refresh the selection. I tried 2 diffrent things.
1) SelectedItem=null; 
     RaisePropertyChanged("SelectedItem"); this doesnt work even in xaml SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
2) 
     private void dataGrid_GridTapped(object sender, GridTappedEventsArgs e)
        {
            listWorkouts.Opacity = 1.0;
            listWorkouts.IsEnabled = true;
            if((sender as SfDataGrid).SelectedItem !=null)               
               listWorkouts.SelectionController.ClearSelection();
        }

this event is not getting fired when I tap on SelectedItem. 
So what other option do I have? 

PS, please make sure that we understand each other. I talk only about navigating back to the page.  

1 Reply

DS Divakar Subramaniam Syncfusion Team January 20, 2017 09:53 AM UTC

Hi Emil, 
 
Thanks for contacting Syncfusion Support. 
 
We have checked your query. We assumed that you have navigated to the next page through SfDataGrid.SelectionChanged event. If you set SelectionMode as “SingleDeSelect” then the selection changed event will be fired both while selecting and deselecting. That might be the reason in your case. However, you can overcome this by using the below code snippet. 
private void DataGrid_SelectionChanged(object sender, GridSelectionChangedEventArgs e) 
{ 
    if (e.AddedItems.Count > 0) 
        this.Navigation.PushAsync(new DetailsPage()); 
} 
 
We have attached a simple sample for your reference and you can download the same from the below link. 
 
If your query or requirement is not related to the case we have mentioned, then please do revert us with the clear information about your query along with modified sample reproducing the issue which will help us to analyze further. 
 
Regards, 
Divakar. 
 


Loader.
Live Chat Icon For mobile
Up arrow icon