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

SfNavigationDriver and SfDataGrid together null exception

I am getting exception below when I use sfDataGrid inside SfNavigationDriver
Xamarin caused by: android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object.
at Xamarin.Forms.Platform.Android.ListViewAdapter..ctor (Android.Content.Context context, Android.Widget.ListView realListView, Xamarin.Forms.ListView listView) [0x00096] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ListViewAdapter.cs:56
at Xamarin.Forms.Platform.Android.ListViewRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs`1[TElement] e) [0x00100] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ListViewRenderer.cs:142
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000f4] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:193
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:129
at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x0001f] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Platform.cs:289
at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x00023] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:74
at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00104] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:207
at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:58
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:337
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x00111] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:196
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:129
at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x0001f] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Platform.cs:289
at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x00023] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:74
at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00104] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:207
I saw that there are already similar threads for listview and I believe thatSfDataGrid is inherited from listview and it might be the same error. You repliedhereas it is XF latest release related but I am not sure if it is same issue for my case because using latest version my xaml below works fine. So sfgrid:SfDataGrid indeed works with latest release of XF.



AutoGenerateColumns="False"
AllowSorting="True"
IsEnabled="True"
ColumnSizer="Star"
AllowSwiping="True"
MaxSwipeOffset="180"
GridTapped="dataGrid_GridTapped"
SelectionMode="{Binding GridSelectionMode}"
SelectionChanged="SuperSetSelectionChanged"
AutoExpandGroups="True"
AllowGroupExpandCollapse="True"
RowHeight="100" ItemsSource="{Binding Items}"
SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}" VerticalOptions="FillAndExpand">





...

But once I lay everything inside a SfNavigationDriver, I am getting same null exception. So what is the problem here if this is not XF related?








...




Text="{Binding SearchText, Mode=TwoWay}"
SuggestionItemDataTemplate="{StaticResource SuggestionItemTemplate}"
Placeholder="Search Items here!"
ShowSearchButton="False"
SearchBackgroundColor="White"
SearchTextColor = "Black"
SearchBorderColor = "Yellow"
SuggestionBackgroundColor="White"
SearchCommand="{Binding FindItems}"
Suggestions="{Binding Items, Mode=TwoWay}"
/>
AutoGenerateColumns="False"
AllowSorting="True"
IsEnabled="True"
ColumnSizer="Star"
AllowSwiping="True"
MaxSwipeOffset="180"
GridTapped="dataGrid_GridTapped"
SelectionMode="{Binding GridSelectionMode}"
SelectionChanged="SuperSetSelectionChanged"
AutoExpandGroups="True"
AllowGroupExpandCollapse="True"
RowHeight="100" ItemsSource="{Binding Items}"
SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}" VerticalOptions="FillAndExpand">

....





3 Replies

EM Emil December 21, 2016 06:06 PM UTC

Sorry for the format Above

I am getting exception below when I use sfDataGrid inside SfNavigationDriver
Xamarin caused by: android.runtime.JavaProxyThrowable: System.NullReferenceException: Object reference not set to an instance of an object.
at Xamarin.Forms.Platform.Android.ListViewAdapter..ctor (Android.Content.Context context, Android.Widget.ListView realListView, Xamarin.Forms.ListView listView) [0x00096] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ListViewAdapter.cs:56
at Xamarin.Forms.Platform.Android.ListViewRenderer.OnElementChanged (Xamarin.Forms.Platform.Android.ElementChangedEventArgs`1[TElement] e) [0x00100] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Renderers\ListViewRenderer.cs:142
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x000f4] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:193
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:129
at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x0001f] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Platform.cs:289
at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x00023] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:74
at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00104] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:207
at Xamarin.Forms.Platform.Android.VisualElementPackager.Load () [0x00000] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:58
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetPackager (Xamarin.Forms.Platform.Android.VisualElementPackager packager) [0x00007] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:337
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].SetElement (TElement element) [0x00111] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:196
at Xamarin.Forms.Platform.Android.VisualElementRenderer`1[TElement].Xamarin.Forms.Platform.Android.IVisualElementRenderer.SetElement (Xamarin.Forms.VisualElement element) [0x00027] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementRenderer.cs:129
at Xamarin.Forms.Platform.Android.Platform.CreateRenderer (Xamarin.Forms.VisualElement element) [0x0001f] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\Platform.cs:289
at Xamarin.Forms.Platform.Android.VisualElementPackager.AddChild (Xamarin.Forms.VisualElement view, Xamarin.Forms.Platform.Android.IVisualElementRenderer oldRenderer, Xamarin.Forms.Platform.Android.RendererPool pool, System.Boolean sameChildren) [0x00023] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:74
at Xamarin.Forms.Platform.Android.VisualElementPackager.SetElement (Xamarin.Forms.VisualElement oldElement, Xamarin.Forms.VisualElement newElement) [0x00104] in C:\BuildAgent2\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\VisualElementPackager.cs:207
I saw that there are already similar threads for listview and I believe thatSfDataGrid is inherited from listview and it might be the same error. You repliedhereas it is XF latest release related but I am not sure if it is same issue for my case because using latest version my xaml below works fine. So sfgrid:SfDataGrid indeed works with latest release of XF.


 <ContentView.Content>
        <StackLayout Orientation="Vertical">
          <xlabs:AutoCompleteView x:Name="MyAutoComplete"
                    Text="{Binding SearchText, Mode=TwoWay}"
                    SuggestionItemDataTemplate="{StaticResource SuggestionItemTemplate}"
                    Placeholder="Search Items here!"
                    ShowSearchButton="False"
                   SearchBackgroundColor="White"
                              SearchTextColor = "Black"
                              SearchBorderColor = "Yellow"
                              SuggestionBackgroundColor="White"
                    SearchCommand="{Binding FindItems}"
                    Suggestions="{Binding Items, Mode=TwoWay}"
      />
          <sfgrid:SfDataGrid  ScrollingMode="PixelLine"  x:Name="listItems"
                        AutoGenerateColumns="False"
                        AllowSorting="True"
                           IsEnabled="True"
                        ColumnSizer="Star"
                        AllowSwiping="True"
                        MaxSwipeOffset="180"
                        GridTapped="dataGrid_GridTapped"
                        SelectionMode="{Binding GridSelectionMode}"
                              SelectionChanged="SuperSetSelectionChanged"
                         AutoExpandGroups="True"
                          AllowGroupExpandCollapse="True"
                        RowHeight="100" ItemsSource="{Binding Items}"
             SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}"  VerticalOptions="FillAndExpand">
 
....
 

    

  </ContentView.Content>


But once I lay everything inside a SfNavigationDriver, I am getting same null exception. So what is the problem here if this is not XF related?

<ContentView.Content>
    <navigation:SfNavigationDrawer x:Name="navigationDrawer" Position="Right" Transition="SlideOnTop" DrawerWidth="300">
      <navigation:SfNavigationDrawer.DrawerHeaderView>
        <Grid x:Name="headerLayout" BackgroundColor="#1aa1d6" >
          <Label x:Name="header"  Text="FILTERS" FontSize="14" TextColor="White"  VerticalTextAlignment="Center" HorizontalTextAlignment="Center"  />
        </Grid>
      </navigation:SfNavigationDrawer.DrawerHeaderView>
      <navigation:SfNavigationDrawer.DrawerContentView>
        <StackLayout Orientation="Vertical" BackgroundColor="White">
        ...
        </StackLayout>
      </navigation:SfNavigationDrawer.DrawerContentView>
      <navigation:SfNavigationDrawer.ContentView>
        <StackLayout Orientation="Vertical">
          <xlabs:AutoCompleteView x:Name="MyAutoComplete"
                    Text="{Binding SearchText, Mode=TwoWay}"
                    SuggestionItemDataTemplate="{StaticResource SuggestionItemTemplate}"
                    Placeholder="Search Items here!"
                    ShowSearchButton="False"
                   SearchBackgroundColor="White"
                              SearchTextColor = "Black"
                              SearchBorderColor = "Yellow"
                              SuggestionBackgroundColor="White"
                    SearchCommand="{Binding FindItems}"
                    Suggestions="{Binding Items, Mode=TwoWay}"
      />
          <sfgrid:SfDataGrid  ScrollingMode="PixelLine"  x:Name="listItems"
                        AutoGenerateColumns="False"
                        AllowSorting="True"
                           IsEnabled="True"
                        ColumnSizer="Star"
                        AllowSwiping="True"
                        MaxSwipeOffset="180"
                        GridTapped="dataGrid_GridTapped"
                        SelectionMode="{Binding GridSelectionMode}"
                              SelectionChanged="SuperSetSelectionChanged"
                         AutoExpandGroups="True"
                          AllowGroupExpandCollapse="True"
                        RowHeight="100" ItemsSource="{Binding Items}"
             SelectedItem="{Binding SelectedItem, Mode=OneWayToSource}"  VerticalOptions="FillAndExpand">
 
....
 
 
    </navigation:SfNavigationDrawer>
    
  </ContentView.Content>


EM Emil December 21, 2016 06:25 PM UTC

opps, sorry actually I was wrong it has nothing to do with SfDataGrid. SfDataGrid works just fine inside a SfNavigationDrawer. I had another control which is xlabs:AutoCompleteView, this is the one causing error with the listView. But this tool is also working fine unless I use SfNavigationDrawer around it. How is related together? does SfNavigationDrawer tiggers some error on ListView? 
I am going try sfAutoCompleteView to see if it has same error. 


PK Pavendhan Kumar Syncfusion Team December 22, 2016 12:49 PM UTC

Hi Emil,

Thank you for contacting Syncfusion support.

We would like to inform that the issue "Adding list view in NavigationDrawer’s throws exception" is occurring due to Xamarin Forms latest versions. We request you to use the older version (i.e.2.3.1.114) of Xamarin forms till the has been resolved. And also there is a query already raised in Xamarin forum regarding the same. Please find the link for the query.

https://forums.xamarin.com/discussion/80549/android-listview-crashes-not-on-ios-or-uwp  

And We have filed a bug report about "adding a list view in NavigationDrawer crashes the app on Xamarin.Forms Android platform" and please find the link for the report in below.

Link: https://bugzilla.xamarin.com/show_bug.cgi?id=46563  

Regards,
Pavendhan K. 
 


Loader.
Live Chat Icon For mobile
Up arrow icon