How to avoid Object Reference Error when calling Frame.Navigate in UWP

-1

In my UWP app created with Template Studio, I am tryiing to navigate to a Setup Page. But I''m getting the following error:

System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of an object. Source=CWON StackTrace: at CWON.Views.MainPage..ctor() in C:\ProjectsOneNote\CWON\CWON\Views\MainPage.xaml.cs:line 104

Here is my code:

  string tempNoteBook = Globals.CurrentNotebookId;

        if (tempNoteBook == "")
        {
            Frame.Navigate(typeof(Views.SetupPage));
        }

The page I'm trying to call is :

public SetupPage()
    {
        InitializeComponent();
        Loaded += SetupPage_Loaded;

    }

I've tried to make public static SetupPage() , but that doesn't work.

Within the SetupPage, I have another Navigation call and it works ok.

Frame.Navigate(typeof(MainPage));

c#
uwp
windows-template-studio
asked on Stack Overflow Mar 22, 2020 by Trey Balut

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0