locked
Getting NullReferenceException while navigating to popuppage RRS feed

  • Question

  • User353937 posted

    MessagingCenter.Unsubscribe(this, "CaptureFormName"); MessagingCenter.Subscribe(this, "CaptureFormName", async x => { var bindingContext = new PageViewModel { ScreenName = "StaticName" }; await Application.Current.MainPage.Navigation.PushAsync(new PagePopUp() { CloseWhenBackgroundIsClicked = false, BindingContext = bindingContext });
    }); Above is my code and i am getting the bellow Exception {System.NullReferenceException: Object reference not set to an instance of an object. at Project.PageName+<<-ctor>b_10>d.MoveNext () [0x0002f] in ProjectPath\PageName.xaml.cs:26 } Thanks in Advance.

    Thursday, February 21, 2019 6:00 AM

All replies

  • User42522 posted

    @"Dilipkumar.7949" said: MessagingCenter.Unsubscribe(this, "CaptureFormName"); MessagingCenter.Subscribe(this, "CaptureFormName", async x => { var bindingContext = new PageViewModel { ScreenName = "StaticName" }; await Application.Current.MainPage.Navigation.PushAsync(new PagePopUp() { CloseWhenBackgroundIsClicked = false, BindingContext = bindingContext });
    }); Above is my code and i am getting the bellow Exception {System.NullReferenceException: Object reference not set to an instance of an object. at Project.PageName+<<-ctor>b_10>d.MoveNext () [0x0002f] in ProjectPath\PageName.xaml.cs:26 } Thanks in Advance.

    You are defining PagePopUp in the delegate itself. I don't know if that works. Create a Page class separately in the project and then navigate to it.

    Thursday, February 21, 2019 2:55 PM