Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Navigation between pages in WPF?

Tags:

c#

window

wpf

xaml

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?

like image 940
Ben Clarke Avatar asked Nov 18 '13 15:11

Ben Clarke


People also ask

How do I navigate between pages in WPF?

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.

How do I redirect a page to another page in WPF?

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.


1 Answers

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.

like image 65
Bernoulli IT Avatar answered Sep 30 '22 15:09

Bernoulli IT