0

I want to know how can I navigate between pages in a frame sending parameters.

I've tried this on my Navigation View:

 if (tag != null)
        {
            switch (tag)
            {
                case "Users":
                    User user = new User();
                    MainFrame.Navigate(typeof(UserManagementPage), user);
                    break;
            }

In the View (Page) I just have this code:

 public UserManagementPage(User user)
        {
            this.InitializeComponent();
        }

When I click on the NavigationViewItem that was supposed to navigate the frame to the UserManagementPage the app throws the following exception:

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

at MainFrame.Navigate(typeof(UserManagementPage), user);

I've tried to remove the parameter from the page constructor and it worked fine so I think the problem is on the way I'm trying to send the parameter.

Anyone knows how can I do this right?

PS: The problem isn't on the frame because all the other pages are working fine.

David Simões
  • 303
  • 4
  • 11
  • Show the full stacktrace. – Immersive Jul 14 '21 at 15:23
  • 1
    `MainFrame` is probably null, but a stack trace would help. This is really up to you to debug though -- with a debugger, it's easy to see what thing is null. I've linked your question to one which has some great advice on finding and fixing NullReferenceExceptions – canton7 Jul 14 '21 at 15:24

0 Answers0