Use SFDataForm INSIDE sfNavigationDrawer

Hello, my name is Uriel. I am trying to put a sfDataform inside a sfnavigationdrawer contentpage. I use the tutorial to create an app with a sfdataform and it worked perfectly. The problem is when I try to put the same form inside a contentpage that is a  "navigation page" of my navigationdrawer the follow error appears :"System.NullReferenceException: Object reference not set to an instance of an object.".

The error happens when I do "navigationDrawer.ContentView = new MyContentPage().Content;"


I have been working on it for a week and I can' resolve it.

Sorry for my english and thank you in advice,

Uriel.

8 Replies

SV Srinivasan Vasu Syncfusion Team March 16, 2018 10:57 AM UTC

Hi Uriel, 
 
Thanks for contacting Syncfusion support. 
 
 
We have checked your query and we are able to reproduce the reported “NullReferenceException issue in SfDataForm while adding with SfNavigationDrawer in Xamarin.Forms. We have logged a report for the same and the fix will be included in our upcoming Volume 1 SP1 release 2018 which is expected to be available by end of the month March 2018. We appreciate your patience until then. 
 
Regards, 
Srinivasan 



UR Uriel March 16, 2018 03:01 PM UTC

Hello srinivasan, thank you for your help. I have been using other controls like sfpopuplayout inside a sfnavigationdrawer and maybe both error are similar. 
The error is fired when the "popoup main layout" is inside other layout.
The error happens when i do popupLayout.Show(mainLayout);


The exception message is:

System.NullReferenceException: Object reference not set to an instance of an object.
  at Syncfusion.XForms.PopupLayout.SfPopupLayout.GetViewParentPage (Xamarin.Forms.View view) [0x0002a] in <d42f7f4028dc44ccaff50ec2d90c5369>:0 
  at Syncfusion.XForms.PopupLayout.SfPopupLayout.SetSfPopupLayoutAsContent (Xamarin.Forms.View rootView) [0x00000] in <d42f7f4028dc44ccaff50ec2d90c5369>:0 
  at Syncfusion.XForms.PopupLayout.SfPopupLayout.Show (Xamarin.Forms.View rootView) [0x00037] in <d42f7f4028dc44ccaff50ec2d90c5369>:0 
  at MemoApp.Views.DatosPacientes.BtnAceptar_Clicked (System.Object sender, System.EventArgs e) [0x0025b] 

I understand that the problem is when the app try to use the method GetViewParentPage() it returns null. 

Thank you very much for your time.

Uriel.


JM Jeyasri M Syncfusion Team March 19, 2018 11:34 AM UTC

Hi Uriel 
 
Regarding using SfPopupLayout inside a SfNavigationdrawer. 
 
When the SfPopupLayout is the root view, calling SfPopupLayout.Show() method, displays the popup and there is no need to pass the mainLayout as the parameter.  
 
From your query, we suspect that you have set the root view as the SfPopupLayout and passing the mainLayout in the SfPopupLayout.Show(mainLayout), which is the wrong use case. For more details please refer the UG link which is given below.  
  
Popup can be displayed in view in 2 types.   
  
Type A: Displaying pop-up when the SfPopupLayout is set as root view, call SfPopupLayout.Show() method.  
              
  
Type B: Displaying pop-up when the SfPopupLayout is not set as root view, pass the root view to the parameter of the SfPopupLayout.Show(mainLayout)  
  
  
In case if you are still facing the issue after following the above steps, then please do revert us with the details about the settings that you have applied for the SfPopupLayout and its parent and children and the steps for reproducing the issue which will be much helpful for replicating the issue in our side and provide a faster solution.  
  
Regards,  
Jeyasri M 



UR Uriel March 31, 2018 04:01 PM UTC

Hello, Jeyasri i couldn't resolve my problem. I have 2 stacklayout. The main layout contains the grid that is required by the SfNavigationDrawer. The SFpopouplayout works perfectly when i set the mainlayout. The problem is when i do that, the SFNavigationDrawer hamburguer menu doens't work. If i do "popuplayout.show(secondlayout)", an "System.NullReferenceException: Object reference not set to an instance of an object." error apears.
I want to show the popuplayout but i don't want to loose the sfnavigationdrawer menu. 

Thank you in advice!

Here is my code.


 <ContentPage.Content>
        <StackLayout x:Name="mainLayout">
            <Grid x:Name="headingGrid" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="50" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <Grid BackgroundColor="#00a0e1" >
                    <Image x:Name="headerGradiant" HeightRequest="50" Aspect="AspectFill" />
                    <StackLayout Orientation="Horizontal">
                        <Button FontSize="20" x:Name="btn" HeightRequest="28" Clicked="Btn_Clicked" HorizontalOptions="Start" WidthRequest="28" />
                        <Label x:Name="headerLabel" FontSize="20" HorizontalTextAlignment="Center" XAlign="Center" HorizontalOptions="Center" VerticalTextAlignment="Center" HeightRequest="50" TextColor="White" />
                    </StackLayout>
                </Grid>
            </Grid>
        </StackLayout>
       <StackLayout Grid.Row="1" Padding="50,50,50,50" BackgroundColor="White"  x:Name="secondLayout">
<Button x:Name="clickToShowPopup" Text="ClickToShowPopup" VerticalOptions="Start" HorizontalOptions="FillAndExpand" />
        </StackLayout>

    </ContentPage.Content>
</ContentPage>





JM Jeyasri M Syncfusion Team April 2, 2018 05:19 AM UTC

Hi Uriel, 
  
Regarding issue with adding SfDataForm in SfNavigationDrawer. 
 
We are glad to announce that our Essential Studio Volume 1, SP 1 2018 (v16.1.0.32) is rolled out, the issue fix of “NullReferenceException issue in SfDataForm while adding with SfNavigationDrawer in Xamarin.Forms” has been included and is available for download under the following link. 
  
                                       
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance. 
 
Regards, 
Jeyasri M. 



SV Srinivasan Vasu Syncfusion Team April 3, 2018 12:23 PM UTC

Hi Uriel,  
  
Regarding SfPopupLayout query: 
  
As per your update, you have passed the mainLayout and the secondLayout in the SfPopupLayout.Show() method. But you need to pass the ContentPage.Content to the SfPopupLayout which is the root view of the page. So, pass the this.Content in the SfPopupLayout.Show() method.   
  
Please find the code snippet below to show the popup.  
  
SfPopupLayout.Show(this.Content);  
  
Regards,  
Srinivasan 



UR Uriel April 14, 2018 05:11 PM UTC

Hello, I have updated the reference to version .32 but I'm still facing the same problem.

Can you help me?

Thank you for your time.


Regarding issue with adding SfDataForm in SfNavigationDrawer. 
 
We are glad to announce that our Essential Studio Volume 1, SP 1 2018 (v16.1.0.32) is rolled out, the issue fix of “NullReferenceException issue in SfDataForm while adding with SfNavigationDrawer in Xamarin.Forms” has been included and is available for download under the following link. 
  
                                       
We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance. 
 
Regards, 
Jeyasri M. 


SV Srinivasan Vasu Syncfusion Team April 17, 2018 06:34 AM UTC

Hi Uriel, 
 
We have ensured the issue with “NullReferenceException in SfDataForm while adding in SfNavigationDrawer in Xamarin.Forms” in version 16.1.0.32 which is working fine from our side. We have attached the tested sample along with this response. Please find the sample and video from below link. 
 
 
 
Note: Please ensure the all old Syncfusion Version Nuget Assemblies are removed properly. 
 
Please refer the below link to clear nuget cache: 
 
Could you please ensure the issue from your side using the above sample? Still, you are facing the same issue in your side, please modify the sample along with replication procedure. It will be helpful for us to provide you better solution with high priority. 
 
Regards, 
Srinivasan 


Loader.
Up arrow icon