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.
Unfortunately, activation email could not send to your email. Please try again.

SfNavigationDriver and SfDataGrid together null exception

Thread ID:

Created:

Updated:

Platform:

Replies:

127959 Dec 21,2016 01:02 PM Dec 22,2016 07:49 AM Xamarin.Forms 3
loading
Tags: SfNavigationDrawer
Emil
Asked On December 21, 2016 01:02 PM

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">

....





Emil
Replied On December 21, 2016 01:06 PM

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>

Emil
Replied On December 21, 2016 01:25 PM

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. 

Pavendhan Kumar [Syncfusion]
Replied On December 22, 2016 07:49 AM

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. 
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;