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

NullReferenceException on .show()

The exception is thrown only when I use the show() method, here's the code:

public partial class DetailOS : ContentPage
    {
        SfPopupLayout Popup { get; set; }
        public string MotivoCancel { get; set; }
        Models.Manutencao.Pedido Pedido { get; set; }

        public DetailOS (Models.Manutencao.Pedido obj)
{
    InitializeComponent ();
            Pedido = obj;
            Popup = new SfPopupLayout();
            Popup.PopupView.AppearanceMode = AppearanceMode.TwoButton;
            Popup.PopupView.HeaderTitle = "Cancelar OS";
            Popup.PopupView.PopupStyle = new PopupStyle {
                AcceptButtonBackgroundColor = Color.FromHex("#009530"),
                AcceptButtonTextColor = Color.White,
                DeclineButtonBackgroundColor = Color.FromHex("#009530"),
                DeclineButtonTextColor = Color.White
            };
            Popup.PopupView.ContentTemplate = new DataTemplate(() => {
                var txt = new Entry { Placeholder = "Informe o motivo" };
                txt.BindingContext = this;
                txt.SetBinding(Entry.TextProperty, "MotivoCancel");
                return txt;
            });
            Popup.PopupView.DeclineButtonText = "VOLTAR";
            Popup.PopupView.AcceptButtonText = "CANCELAR";
            Popup.PopupView.AcceptCommand = new Command(Cancelar);
            BindingContext = new ViewModels.Manutencao.DetailOS () { Pedido = obj, Navigation = Navigation };
        }

        async void CancelarPopUp(object sender, EventArgs e)
        {
            try {
                if (Pedido.Status == "aberto") {
                    Popup.Show();
                } else {
                    await DisplayAlert("Acesso Restrito", "Essa OS não pode ser cancelada em seu atual estágio do processo", "OK");
                }
            } catch (Exception ex) {
                await DisplayAlert("Exceção : Contate o administrador", ex.Message, "dismiss");
            }
        }
    }

Didn't include the whole class here, just the methods that have some interaction with the Popup.
I made sure to include the xmlns:syncfusion="clr-namespace:Syncfusion.XForms.PopupLayout;assembly=Syncfusion.SfPopupLayout.XForms" in the xaml.
The stack trace is the following:

System.NullReferenceException: Object reference not set to an instance of an object.
  at Syncfusion.XForms.Android.PopupLayout.RendererHelper.GetNativeRendererForFormsView (Xamarin.Forms.View view, Syncfusion.XForms.PopupLayout.SfPopupLayout valid) [0x00039] in :0 
  at Syncfusion.XForms.Android.PopupLayout.RendererHelper.ConvertFormsToNativeView (Syncfusion.XForms.PopupLayout.SfPopupLayout formsSfPopupLayout, Xamarin.Forms.View view, Android.Views.ViewGroup+LayoutParams layoutParams) [0x00000] in :0 
  at Syncfusion.XForms.Android.PopupLayout.RendererHelper.SetContentTemplateToNativePopupView (Syncfusion.XForms.Android.PopupLayout.PopupView nativePopupView, Syncfusion.XForms.PopupLayout.PopupView formsPopupView) [0x00037] in :0 
  at Syncfusion.XForms.Android.PopupLayout.RendererHelper.MapPopupViewProperties (System.String propertyName, Syncfusion.XForms.PopupLayout.PopupView formsPopupView, Syncfusion.XForms.Android.PopupLayout.PopupView nativePopupView) [0x00213] in :0 
  at Syncfusion.XForms.Android.PopupLayout.PopupLayoutDependencyService.MapPopupViewProperties (System.String propertyName) [0x00028] in :0 
  at Syncfusion.XForms.Android.PopupLayout.PopupLayoutDependencyService.CreateNativePopup (System.Object nativeObject, Syncfusion.XForms.PopupLayout.SfPopupLayout popup, System.Boolean canMap) [0x0012d] in :0 
  at Syncfusion.XForms.Android.PopupLayout.PopupLayoutDependencyService.Show (System.Object nativeObject, Syncfusion.XForms.PopupLayout.SfPopupLayout formsPopup) [0x00007] in :0 
  at Syncfusion.XForms.PopupLayout.SfPopupLayout.Show () [0x0000c] in <71ecd4ed02a74af885d8e5b7876b2bda>:0 
  at GFA.Views.Manutencao.DetailOS+d__13.MoveNext () [0x0004c] in C:\wampNew\www\App_GFA\GFA\GFA\GFA\Views\Manutencao\DetailOS.xaml.cs:44


Edit: I'm using version 16.4.0.46

10 Replies

SP Subburaj Pandian Veluchamy Syncfusion Team January 18, 2019 06:19 AM

Hi Gabriel, 
 
Thank you for contacting Syncfusion support. 
 
Based on the provided information, we have checked the reported issue with Popup layout when showing in Xamarin.Forms and it is working fine from our side. We have prepared sample based on the given code, please find the same by the following link. 
 
Sample link: PopupSampleF142074  
 
In the sample, we have shown the Pop-up layout in the button click and working as expected in the Syncfusion update version 16.4.0.46. 
 
If the sample doesn’t meet your requirement, could you please modify the sample based on your scenario with replication procedure. It will be helpful for us to check on it and provide you the solution. 
 
Regards,
Subburaj Pandian V  



PL Philippe Leybaert February 8, 2019 10:08 AM

Same issue here, worked fine on 16.4.0.46, but crashes with a NullReferenceException on 16.4.0.52

Stack trace:

NullReferenceException : Object reference not set to an instance of an object

at Syncfusion.XForms.iOS.PopupLayout.RendererHelper.GetNativeRendererForFormsView (Xamarin.Forms.View view, Syncfusion.XForms.PopupLayout.SfPopupLayout valid) [0x00039] in :0 
at Syncfusion.XForms.iOS.PopupLayout.RendererHelper.ConvertFormsToNativeView (Xamarin.Forms.View view, CoreGraphics.CGRect size, Syncfusion.XForms.PopupLayout.SfPopupLayout formsSfPopupLayout) [0x00000] in :0 
at Syncfusion.XForms.iOS.PopupLayout.RendererHelper.SetContentTemplateToNativePopupView (Syncfusion.XForms.iOS.PopupLayout.PopupView nativePopupView, Syncfusion.XForms.PopupLayout.PopupView formsPopupView) [0x00052] in :0 
at Syncfusion.XForms.iOS.PopupLayout.RendererHelper.MapPopupViewProperties (System.String propertyName, Syncfusion.XForms.PopupLayout.PopupView formsPopupView, Syncfusion.XForms.iOS.PopupLayout.PopupView nativePopupView) [0x00213] in :0 
at Syncfusion.XForms.iOS.PopupLayout.PopupLayoutDependencyService.MapPopupViewProperties (System.String propertyName) [0x00028] in :0 
at Syncfusion.XForms.iOS.PopupLayout.PopupLayoutDependencyService.CreateNativePopup (System.Object nativeObject, Syncfusion.XForms.PopupLayout.SfPopupLayout popup, System.Boolean canMap) [0x0012c] in :0 
at Syncfusion.XForms.iOS.PopupLayout.PopupLayoutDependencyService.ShowRelativeToView (System.Object nativeObject, Syncfusion.XForms.PopupLayout.SfPopupLayout formsPopup, Xamarin.Forms.View relative_view, Syncfusion.XForms.PopupLayout.RelativePosition relative_position, System.Double absoluteX, System.Double absoluteY, System.Boolean canMap) [0x00007] in :0 
at Syncfusion.XForms.PopupLayout.SfPopupLayout.ShowRelativeToView (Xamarin.Forms.View relativeView, Syncfusion.XForms.PopupLayout.RelativePosition relativePosition, System.Double absoluteX, System.Double absoluteY) [0x00033] in :0 




PL Philippe Leybaert February 8, 2019 11:04 AM

Since 16.4.0.52, the following code throws a NullReferenceException every time (see stack trace above). This worked fine in 16.4.0.48

private SfPopupLayout ShowPopup(View popupContent, int width, int height, View triggerView)
        {
            popupContent.HorizontalOptions = LayoutOptions.Center;
            popupContent.VerticalOptions = LayoutOptions.Center;

            var grid = new Grid()
            {
                Children = {popupContent},
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor = Color.Black,
            };

            SfPopupLayout popup = new SfPopupLayout
            {
                Padding = 0,
                PopupView =
                {
                    WidthRequest = width,
                    HeightRequest = height,
                    ShowFooter = false,
                    ShowHeader = false,
                    AnimationMode = AnimationMode.None,
                    ContentTemplate = new DataTemplate(() => grid),
                    PopupStyle =
                    {
                        
                        CornerRadius = 2,
                        BorderThickness = 2,
                        BorderColor = Color.FromHex("#222222")
                    }
                }
            };

            popup.ShowRelativeToView(triggerView, RelativePosition.AlignTopLeft,width/2+15,-10);

            return popup;
        }


PL Philippe Leybaert February 8, 2019 04:17 PM

Turns out that this is related to the Xamarin Forms update. It crashes on 3.5.0 but works on 3.4.0


SP Subburaj Pandian Veluchamy Syncfusion Team February 11, 2019 02:26 AM

Hi Philippe, 
 
We regret for the inconvenience caused. 
 
We have already found and logged issue report for the mentioned issue “Throws error when setting template to the Popup Layout” in Xamarin.Forms update version 3.5. The issue occurs only when the project Xamarin.Forms update version above 3.5 and it is not occurring the previous updates.  
 
We will fix this issue and include the issue fix in our upcoming Volume 1 main release update and it will be expected to be available by mid of March 2019.  
 
You can now track the status of this issue and contact us for any further inquiries through this link, 
 
 
We appreciate your patience and please use the earlier Xamarin.Forms updates until then.  
 
Regards,
Subburaj Pandian V  



SP Subburaj Pandian Veluchamy Syncfusion Team February 19, 2019 02:20 AM

Hi Philippe, 
  
We are glad to announce that our latest weekly NuGet package update version 16.4.0.53 has been rolled out with the issue fix of “Popup layout crashing issue in Xamarin.Forms update 3.5” and is available for download (nuget.org). 
 
We thank you for your support and appreciate your patience in waiting for this update. Please get in touch with us if you would require any further assistance. 
  
Regards,
Subburaj Pandian V   



SA Siwakron Apichitsopa May 5, 2019 04:49 AM

Dear  Syncfusion Support.

I read your reply and other topic about update new version (Update Xamarin and New Syncfusion 171.0.38). But It can not solve this problem.

Best regards,
Siwakorn Apichitsopa.


SP Subburaj Pandian Veluchamy Syncfusion Team May 6, 2019 08:03 AM

Hi Siwakorn, 
 
We have checked the mentioned issue with Popup layout in our Syncfusion update version 17.1.0.38 and Xamarin.Forms version 3.6 and it is working fine without any issue. Please find the attached sample for your reference, 

Sample link: PopupTemplate3.6

Please check the sample and let us know if you still facing the same issue? If not, please modify the sample based on your scenario and revert us with the more details along with stack trace of the issue. It will be helpful for us to check on it and provide you the solution.  
  
Regards,
Subburaj Pandian V 



VW Victor Wilcox December 2, 2019 11:28 PM

With Xamarin 17.3.0.29, the popup is throwing a null exception error upon calling show.  It works in UWP but crashes in android / iOS builds.



KK Karthikraja Kalaimani Syncfusion Team December 3, 2019 08:12 AM

Hi Victor,

Thank you for your update.

We have checked the issue “Null Reference Exception thrown ” while call SfPopupLayout.Show() in Xamarin Forms Android and Xamarin Forms iOS platform. Unfortunately we could not able to reproduce the issue at our end. We have attached the tested sample for your reference.

Sample link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/PopupTemplate3.6271026082.zip
 
 
SfPopupLayout version  : 17.3.0.29

Xamarin Forms Version : 3.6

If you are still facing the same issue ? please modify the attached sample and revert us back with a clear replication procedure. It will help us to give better solution earlier.

Regards,
Karthik Raja
 


Loader.
Live Chat Icon For mobile
Up arrow icon