Null excption in sfpopouplayout

I have created this popup layou but when i call show method  i have null exception, here below the code behind the view 

popUpLayout.PopupView.HeaderTitle = "Segnalazioni";
            popUpLayout.PopupView.AppearanceMode = AppearanceMode.OneButton;


       public DocView()
        {
            InitializeComponent();

            TapGestureRecognizer t = new TapGestureRecognizer();
            t.NumberOfTapsRequired = 1;
            t.Tapped += T_Tapped;
            GridSub.GestureRecognizers.Add(t);

            popUpLayout.PopupView.HeaderTitle = "Segnalazioni";
            popUpLayout.PopupView.AppearanceMode = AppearanceMode.OneButton;


            popupContent = new Label();
            popupContent.Text = "Manca il tipo pagamento";
            popupContent.BackgroundColor = Color.LightSkyBlue;
            popupContent.HorizontalTextAlignment = TextAlignment.Center;

            templateView = new DataTemplate(() => popupContent);
            popUpLayout.PopupView.ContentTemplate = templateView;
            popUpLayout.PopupView.AcceptButtonText = "OK";
            //popUpLayout.Show();
        }

 private void T_Tapped(object sender, EventArgs e)
        {
            try
            {
                popUpLayout.Show();
            }
            catch (Exception Ex)
            {

            }
            
        }

in the xaml

 <sfPopup:SfPopupLayout x:Name="popUpLayout">
        <sfPopup:SfPopupLayout.Content>

            <Grid RowSpacing="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="52"/>
                    <RowDefinition />
                    <RowDefinition Height="45"/>
                </Grid.RowDefinitions>

                <iMioCoreControls:iMioCommandBar x:Name="CommandBar" ShowBackIcon="False" Grid.Row="0" Title="VORD Num.: 11443 del 21/02/2018"/>

                <sftabView:SfTabView Grid.Row="1" DisplayMode="Text" TabHeaderBackgroundColor="{StaticResource Primary}" VisibleHeaderCount="3" EnableSwiping="False">
                    <sftabView:SfTabView.SelectionIndicatorSettings>
                        <sftabView:SelectionIndicatorSettings Color="White" Position="Bottom" StrokeThickness="3" />
                    </sftabView:SfTabView.SelectionIndicatorSettings>

                    <ControlLocal:mySfTabItem Title="Testata">
                        <ControlLocal:mySfTabItem.Content>
                            <view:DocHeaderView />
                        </ControlLocal:mySfTabItem.Content>
                    </ControlLocal:mySfTabItem>

                    <ControlLocal:mySfTabItem Title="Righe">
                        <ControlLocal:mySfTabItem.Content>
                            <view:DocRowView />
                        </ControlLocal:mySfTabItem.Content>
                    </ControlLocal:mySfTabItem>

                    <ControlLocal:mySfTabItem Title="Note">
                        <ControlLocal:mySfTabItem.Content>
                            <view:DocNoteView />
                        </ControlLocal:mySfTabItem.Content>
                    </ControlLocal:mySfTabItem>

                </sftabView:SfTabView>

                <!-- BOTTOM COMMAND BAR -->
                <Grid Grid.Row="2" ColumnSpacing="0">
                    <Grid.RowDefinitions>
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>

                    <!--Cancel Button-->
                    <iMioCoreControls:iMioGridButton Grid.Column="0" BackgroundColor="{StaticResource ButtonCancelColor}" IconText="{ x:Static iMioCore:FontAwesomeFont.Undo }" Command="{Binding BackCommand}"/>
                    <!--Totale Doc-->
                    <Grid Grid.Column="1" BackgroundColor="{StaticResource Primary}" Padding="8,5">
                        <Grid ColumnSpacing="0">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="30"/>
                                <ColumnDefinition Width="40"/>
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <iMioCoreControls:iMioGridButton Grid.Column="1" BackgroundColor="{StaticResource Primary}" IconText="{ Binding ImageCheck}" HorizontalOptions="Start" VerticalOptions="Center"/>
                            <Grid x:Name="GridSub" Grid.Column="0">
                                <Label Text="{Binding Path = TotAlert }"  HorizontalOptions="Start" VerticalOptions="Center" FontAttributes="Bold" TextColor="White" />
                            </Grid>

                            <Label Text="{Binding Path = Documento.TotaleImponibile, StringFormat='{0:N}'}"  HorizontalOptions="End" VerticalOptions="Center" FontAttributes="Bold" TextColor="White" Grid.Column="2" />
                        </Grid>
                    </Grid>
                    <!--Save Button-->
                    <iMioCoreControls:iMioGridButton Grid.Column="2" BackgroundColor="{StaticResource ButtonSaveColor}" IconText="{ x:Static iMioCore:FontAwesomeFont.Save }" Command="{Binding SaveCommand}"/>

                </Grid>
            </Grid>
        </sfPopup:SfPopupLayout.Content>
    </sfPopup:SfPopupLayout>

8 Replies

SS Suhasini  Suresh Syncfusion Team May 29, 2018 01:31 PM UTC

Hi Alberto, 
 
Thanks for contacting Syncfusion Support. 
 
We checked your query, we tried to reproduce the issue with reference to the code example in your update. The reported issue “null exception on calling SfPopupLayout.Show()” is not reproduced in our side. You can download the sample in which we tried to replicate the issue. We request you to check the below sample, whether we have prepared the sample as per your requirement.  
 
 
There are chances for the null exception can be thrown from the SfTabView or another custom control you are using in the sample. Please provide us the stack trace of the null exception and the replication procedure to reproduce the issue, which helps us to narrow down the issue.  
 
Regards, 
Suhasini  



AL Alberto May 30, 2018 09:21 AM UTC

I see in your example you do not commented the first  popUpLayout.Show(); when inzialized the view, why?
I write //popUpLayout.Show().

Alberto C.


SK Shivagurunathan Kamalakannan Syncfusion Team June 1, 2018 01:41 PM UTC

Hi Alberto, 
 
We have checked your query, The reported issue “Null exception in sfpopuplayout” does not get reproduced on our side. As you said, We have commented the “popupLayout.Show();” and checked the working of sample. We have also checked by uncommenting the line also. We have recorded a working video and attached for your reference. We have provided both the videos by commenting the “popupLayout.Show();” line and uncommenting the line.  
 
Since the issue reproduces on your side, It would be helpful, If you could provide us the following detail to proceed further and resolve the issue in your side at the earliest. 
  • Since there might be a possibility of NullReferenceException in SfTabView and the custom control that is used in your project. Please provide us the stack trace of the exception.
 
We have attached the video link below which we have recorded the working of the sample. 
 
 
 
Regards, 
Shivagurunathan K 



AL Alberto June 6, 2018 07:09 AM UTC

Hi Suhasini,

here below the exception 

"System.NullReferenceException: Object reference not set to an instance of an object."

and stack trace 

  0x8C in Syncfusion.XForms.Android.PopupLayout.PopupViewRenderer.UpdateTemplateLayout C#
  0x4F in Syncfusion.XForms.Android.PopupLayout.PopupView.UpdatePopupView C#
  0x250 in Syncfusion.XForms.Android.PopupLayout.SfPopupLayout.DisplayPopup C#
  0x35 in Syncfusion.XForms.Android.PopupLayout.SfPopupLayout.set_IsOpen C#
  0x1E in Syncfusion.XForms.Android.PopupLayout.SfPopupRenderer.MapElementPropertiesToControl C#
  0xF in Syncfusion.XForms.Android.PopupLayout.SfPopupRenderer.OnElementPropertyChanged C#
  0x12 in Xamarin.Forms.BindableObject.OnPropertyChanged at D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:153,5 C#
  0x2 in Xamarin.Forms.Element.OnPropertyChanged at D:\a\1\s\Xamarin.Forms.Core\Element.cs:402,4 C#
  0x11D in Xamarin.Forms.BindableObject.SetValueActual at D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:634,5 C#
  0x164 in Xamarin.Forms.BindableObject.SetValueCore at D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:426,5 C#
  0x51 in Xamarin.Forms.BindableObject.SetValue at D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:583,4 C#
  0x5 in Xamarin.Forms.BindableObject.SetValue at D:\a\1\s\Xamarin.Forms.Core\BindableObject.cs:99,4 C#
  0xC in Syncfusion.XForms.PopupLayout.SfPopupLayout.set_IsOpen C#
  0x34 in Syncfusion.XForms.Android.PopupLayout.SfPopupLayout.Show C#
  0x7 in Syncfusion.XForms.Android.PopupLayout.PopupLayoutDependencyService.Show C#
  0x55 in Syncfusion.XForms.PopupLayout.SfPopupLayout.Show C#
> 0x9 in iMioOrderEntryCore.Views.RiepilogoOrdiniView.Setting_ItemClicked at C:\CMP_Sviluppo\Git\iMioMobileOrder\iMioOrderEntryCore\Views\RiepilogoOrdini\RiepilogoOrdiniView.xaml.cs:72,17 C#

I attached also the update of the xaml

sfPopup:SfPopupLayout x:Name="popUpLayout">
       
        <sfPopup:SfPopupLayout.PopupView>
            <sfPopup:PopupView HeightRequest="200" WidthRequest="300" AnimationMode="Fade" HeaderTitle="Popup" ShowFooter="False">
                <sfPopup:PopupView.ContentTemplate>
                    <DataTemplate>
                        <StackLayout Orientation="Horizontal">
                            <Label Text="Popup with switch"/>
                            <Switch IsToggled="True"/>
                        </StackLayout>
                    </DataTemplate>
                </sfPopup:PopupView.ContentTemplate>
            </sfPopup:PopupView>
        </sfPopup:SfPopupLayout.PopupView>
        <sfPopup:SfPopupLayout.Content>
            <Grid RowSpacing="0">
                <Grid.RowDefinitions>
                    <RowDefinition Height="52"/>
                    <RowDefinition />
                </Grid.RowDefinitions>
                <iMioCoreControls:iMioCommandBar x:Name="CommandBar" ShowBackIcon="True" Title="" Grid.Row="0"/>

and below there are the tabs element





DB Deepika Balasubramaniyan Syncfusion Team June 7, 2018 12:56 PM UTC

Hi Alberto, 
  
Thanks for the update, 
  
We have checked the reported null reference exception with the updated code you have provided us and we are not able to reproduce the issue still. Please find the sample link below for reference. 
  
 
Can you please provide us the following details, which will be more helpful in narrowing down the issue.  
  1. Android version of the device you are deploying.
  2. Xamarin.Forms version installed in your project.
  3. Version of the Syncfusion nugets that you are using.
  4. Release configuration of your project.
  5. A simple issue reproducing sample if possible. 
Regards, 
Deepika  



AL Alberto June 7, 2018 03:14 PM UTC

Here below the information :

  1. Android version of the device you are deploying. Androi 7.0
  2. Xamarin.Forms version installed in your project.  3.0.0.530893
  3. Version of the Syncfusion nugets that you are using.  16.1.0.37
  4. Release configuration of your project. In the image attached
  5. A simple issue reproducing sample if possible. I will try to estrapolate that a piece of code



SS Suhasini  Suresh Syncfusion Team June 12, 2018 12:35 PM UTC

Hi Alberto, 
 
We checked the reported issue, it is the frame work side issue which occurs when converting the PCL view to its native view. We will prepare a simple sample and report it in frame work. As of now, for time being, you can disable the “C++ Exceptions and Common Language Runtime Exceptions” to overcome this issue in sample level.  
 
Regards, 
Suhasini 



SS Suhasini  Suresh Syncfusion Team June 26, 2018 09:25 AM UTC

Hi Alberto, 
 
We had checked the reported issue and we were able to fix the reported issue by changing some internal logics in our source to overcome the issue. The fix for the reported issue is included in 2018 Volume 2 main release. With the fix included, exception will not occur when “C++ Exceptions and Common Language Runtime Exceptions” is enabled. 
 
We are glad to announce that our Essential Studio Volume 2, 2018 (Version 16.2.0.41) is rolled out 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, 
Suhasini  


Loader.
Up arrow icon