Hey.
My WPF application is becoming a real pain. I have created a Window and would like to load another page when I click on a button. I assumed this would be straightforward, but it doesn't seem to be. I manage to load the other page by using this.content = new UserPage()
. However, from this UserPage, I can't get back to my main window. I can't use this.content
because the window can't be a child.
Therefore, I searched around and found out I should be using NavigationService to make things a lot easier. I tried to use NavigationService.GetNavigationService(this)
but this didn't work as it always returned null. I figured it's because my main window is derived from Window
and not NavigationWindow
. Is there a way to convert my Window into a NavigationWindow without starting the project again? Whenever I create a new file, there's no NavigationWindow template - only Window, Page, User Control etc...
I tried manually replacing the XAML with NavigationWindow and it ran fine, but the NavigationService method still returned null. There was a bar at the top as well with back and forward arrow (both disabled), but I don't really need this. I would just like to use the Navigate()
method so that I can easily switch between pages.
Any ideas on what I can do?
Thanks for any help, this is driving me nuts! :)