- Home
- Forum
- Xamarin.Forms
- DataGrid Null Reference Exception
DataGrid Null Reference Exception
Hi,
I have a simple setup.
A data grid, which contains two cells.
A data grid, which contains two cells.
A text column and a template column.
The button is bound to a delegate command,
which in turn requests navigation.
Showing a list of items, when the user click edit,
I would navigate to the edit view for the particular record.
The stack trace makes no sense, and is certainly not pointing to an issue in my code,
The stack trace makes no sense, and is certainly not pointing to an issue in my code,
from what I can see.
at Syncfusion.SfDataGrid.XForms.Droid.VirtualizingCellControlRenderer.OnTouchEvent (Android.Views.MotionEvent e) [0x004bd] in <42c48b3923974f68a643233c437121ed>:0
at Android.Views.View.n_OnTouchEvent_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x00010] in /Users/builder/azdo/_work/278/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-30/mcw/Android.Views.View.cs:18560
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.48(intptr,intptr,intptr)
The code for the button is just as simple
The code for the button is just as simple
private async void RequestNavigateToEditItem(Guid? itemId)
{
try
{
if (!itemId.HasValue)
{
return;
}
this.IsBusy = true;
await this.NavigationService.NavigateAsync(name: WellKnownPages.LandingPage); // <----- Exception gets thrown when this is called
}
catch (Exception ex)
{
Crashes.TrackError(ex);
}
finally
{
this.IsBusy = false;
}
}
The Xaml, is super simple still, as I was just getting started
The Xaml, is super simple still, as I was just getting started
<datagrid:SfDataGrid
x:Name="subscriptionGrid"
ColumnSizer="Star"
AutoGenerateColumns="False"
VerticalOptions="FillAndExpand"
ItemsSource="{Binding Items}">
<datagrid:SfDataGrid.Columns>
<datagrid:GridTextColumn HeaderText="Name"
MappingName="Name" />
<datagrid:GridTemplateColumn MappingName="Id">
<datagrid:GridTemplateColumn.CellTemplate>
<DataTemplate>
<buttons:SfButton
Text="Configure"
TextColor="Blue"
ImageSource="success-icon.png"
ShowIcon="True"
ImageWidth="60"
BorderColor="Transparent"
BackgroundColor="Transparent"
ImageAlignment="Start"
Command="{Binding Source={x:Reference subscriptionGrid}, Path=BindingContext.EditItem}"
CommandParameter="{Binding Id}"/>
</DataTemplate>
</datagrid:GridTemplateColumn.CellTemplate>
</datagrid:GridTemplateColumn>
</datagrid:SfDataGrid.Columns>
</datagrid:SfDataGrid>
The items I am binding to can be simplified to this
public class Item
{
public Guid Id {get;set;}
public string Name {get;set;}
}
I have a list of them through this
public ObservableCollection<Item> Items { get; set; }
The edit item command looks like this
public DelegateCommand<Guid?> EditItem { get; set; }
Which is newed up in the constructor like this
this.EditItem = new DelegateCommand<Guid?>(this.RequestNavigateToEditItem);
The items I am binding to can be simplified to this
public class Item
{
public Guid Id {get;set;}
public string Name {get;set;}
}
I have a list of them through this
public ObservableCollection<Item> Items { get; set; }
The edit item command looks like this
public DelegateCommand<Guid?> EditItem { get; set; }
Which is newed up in the constructor like this
this.EditItem = new DelegateCommand<Guid?>(this.RequestNavigateToEditItem);
SIGN IN To post a reply.
6 Replies
1 reply marked as answer
KK
Karthikraja Kalaimani
Syncfusion Team
April 6, 2021 07:40 AM UTC
Hi Louis,
Currently, we are preparing sample to reproduce the issue. We will update the details on or before 8th April 2021. In the meantime, could you please let us know the SfDataGrid version, Xamarin Forms version and Prism version ?
Currently, we are preparing sample to reproduce the issue. We will update the details on or before 8th April 2021. In the meantime, could you please let us know the SfDataGrid version, Xamarin Forms version and Prism version ?
Regards,
Karthik Raja
Karthik Raja
LL
Louis Lewis
April 6, 2021 01:27 PM UTC
Hi Karthik,
Sorry for the delay.
I confirmed its the latest available versions of all packages from nuget.
Regards
Louis
I confirmed its the latest available versions of all packages from nuget.
Regards
Louis
CS
Chandrasekar Sampathkumar
Syncfusion Team
April 7, 2021 07:15 PM UTC
Hi Louis,
Thank you for the update.
As promised, we will update you further details on April 8th, 2021. We appreciate your patience until then.
Regards,
Chandrasekar Sampathkumar
CS
Chandrasekar Sampathkumar
Syncfusion Team
April 8, 2021 06:44 PM UTC
Hi Louis,
Thank you for your patience.
We have prepared simple sample based on the code snippet provided. We regret to let you know that we are not able to replicate the reported issue. We have attached the tested sample for your reference and you can download the same using the following link,
Sample Link: Sample
Could you please replicate the issue for us in the attached sample or could you please share the code snippets for WellKnownPages.LandingPage.
Regards,
Chandrasekar Sampathkumar
Marked as answer
LL
Louis Lewis
April 9, 2021 10:51 AM UTC
Hi,
No worries, behind those statics properties are simple strings.
"/NavigationPage/Landing"
"/NavigationPage/Landing"
"NavigationPage/Login"
Does this help?
Does this help?
CS
Chandrasekar Sampathkumar
Syncfusion Team
April 12, 2021 10:07 AM UTC
Hi Louis,
Thank you for the update.
We are not able to replicate the reported issue using the provided input. We have attached the tested sample for your reference and you can download the same using the following link,
Sample Link: Sample
Could you please run the attached sample and check whether the issue replicated from your side. If the issue is not replicated, could you please replicate the issue for us.
Regards,
Chandrasekar Sampathkumar
SIGN IN To post a reply.
- 6 Replies
- 3 Participants
- Marked answer
-
LL Louis Lewis
- Apr 5, 2021 05:35 PM UTC
- Apr 12, 2021 10:07 AM UTC