I have my WPF application and my button is on a WINDOW that I added and I want the button to open a PAGE when I click it.
NavigationService nav = NavigationService.GetNavigationService(this);
nav.Navigate(new Uri("xamlFeedbackPage.xaml", UriKind.RelativeOrAbsolute));
I have tried that code that was online and my application crashes when I click the button.
Any help?
You can navigate from one Page to another declaratively, by using a Hyperlink, or programmatically, by using the NavigationService. WPF uses the journal to remember pages that have been navigated from and to navigate back to them.
Add a new window, by default it will be called Window1. If you place a button on MainWindow and under the click event of the button put the following code... This will show Window1. Basically you are creating a new instance of the Window1 class.
Take a look at this post and this MSDN article. They contain explanation about what kind of Types are suitable for navigation (pages) and in which container to host them (basically a Frame). Then you should have some succes.
EDIT
Take a look at this extensive example and things will become clear.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With