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

NullReferenceException on .show()

Thread ID:





142074 Jan 17,2019 11:31 AM UTC Dec 3,2019 01:12 PM UTC Xamarin.Forms 10
Tags: SfPopup
Gabriel Theodore
Asked On January 17, 2019 12:37 PM UTC

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") {
                } 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

Subburaj Pandian Veluchamy [Syncfusion]
Replied On January 18, 2019 11:19 AM UTC

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 
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. 
Subburaj Pandian V  

Philippe Leybaert
Replied On February 8, 2019 03:08 PM UTC

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

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 

Philippe Leybaert
Replied On February 8, 2019 04:04 PM UTC

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

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;

Philippe Leybaert
Replied On February 8, 2019 09:17 PM UTC

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

Subburaj Pandian Veluchamy [Syncfusion]
Replied On February 11, 2019 07:26 AM UTC

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.  
Subburaj Pandian V  

Subburaj Pandian Veluchamy [Syncfusion]
Replied On February 19, 2019 07:20 AM UTC

Hi Philippe, 
We are glad to announce that our latest weekly NuGet package update version 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. 
Subburaj Pandian V   

Siwakron Apichitsopa
Replied On May 5, 2019 08:49 AM UTC

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.

Subburaj Pandian Veluchamy [Syncfusion]
Replied On May 6, 2019 12:03 PM UTC

Hi Siwakorn, 
We have checked the mentioned issue with Popup layout in our Syncfusion update version 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.  
Subburaj Pandian V 

Victor Wilcox
Replied On December 3, 2019 04:28 AM UTC

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

Karthikraja Kalaimani [Syncfusion]
Replied On December 3, 2019 01:12 PM UTC

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  :

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.

Karthik Raja


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon