I need to navigate to a Page1.xaml from a Class1.cs.
I tried this way on MainPage.cs
public void test()
{
NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.Relative));
}
And access it in Class1.cs:
...
MainPage window = new MainPage();
window.test();
....
But I get:
"[System.NullReferenceException]
{System.NullReferenceException: Object reference not set to an
instance of an object."
in NavigationService.Navigate(new Uri("/Page1.xaml", UriKind.Relative));
Already read this: How to navigate to a xaml page from class, but didn't work.
Any help how can I do this?
PS: Class1.cs and Page1.cs has different namespaces, if it matters.