Prism Absolute Navigation in DataGrid results into System.NullReferenceException

Dear Syncfusion Team,

I read the forum thread https://www.syncfusion.com/forums/164232/datagrid-null-reference-exception and I have a similar problem, but i m using absolute navigation. I modified your sample code from the above mentied thread and the nullReferenceException gets thrown (Tested on Android). I changed 

LandingPageProp = "LandingPage";

into

Snippet
  LandingPageProp = "/NavigationPage/LandingPage";

The relative navigation works, but not the absolute navigation.


Regards,

Ben Remiche



Attachment: ViewModel_a313f2bd.zip

1 Reply 1 reply marked as answer

KK Karthikraja Kalaimani Syncfusion Team August 25, 2021 01:12 PM UTC

Hi Ben,

Thank you for contacting Syncfusion support. 

We have checked the reported issue with our source and discovered that SfDataGrid children's get disposed while navigating to another page. So, we suggest you to run the prism navigation operation on main thread like the below code snippets. 

Code snippets : 
 
  private async void RequestNavigateToEditItem(Guid? itemId) 
        { 
            try 
            { 
                if (!itemId.HasValue) 
                { 
                    return; 
                } 
  
                this.IsBusy = true; 
                Device.BeginInvokeOnMainThread(() => 
                { 
                     this.NavigationService.NavigateAsync(name: LandingPageProp); 
                }); 
                
              
                 // <----- Exception gets thrown when this is called 
            } 
            catch (Exception ex) 
            { 
                System.Diagnostics.Debug.WriteLine("Exception"); 
            } 
            finally 
            { 
                this.IsBusy = false; 
            } 
        } 
 

Regards,
Karthik Raja
 


Marked as answer
Loader.
Up arrow icon