Navigating between pages in WPF?

I have a WPF application, and my button is in WINDOW, which I added, and I want the button to open PAGE when I click on it.

NavigationService nav = NavigationService.GetNavigationService(this); 
nav.Navigate(new Uri("xamlFeedbackPage.xaml", UriKind.RelativeOrAbsolute));

I tried this code, which was online, and my application crashes when I click the button.

Any help?

+4
source share
2 answers

Check out this post and MSDN article . They contain an explanation of which types are suitable for navigation (page) and in which container to place them (mainly Frame). Then you should have some success.

EDIT

Take a look at this extensive example and everything will become clear.

+1
    public PageFunction1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, RoutedEventArgs e)
    {
        NavigationService nav = NavigationService.GetNavigationService(this);
        nav.Navigate(new Uri("page2.xaml",UriKind.RelativeOrAbsolute));
    }
+1

All Articles