1

So I tried to navigate to another wpf page but it doesn't work at all. Here's what I've been using:

C#:

    private void btnNext_Click(object sender, RoutedEventArgs e)
    {
        Doelen nextPage = new Doelen();
        this.NavigationService.Navigate(nextPage);
    }

XAML:

    <Button x:Name="btnNext" Content="Volgende" Margin="0,10,0,0" Click="btnNext_Click"/>

The big problem here is that Visual Studio says that there is no Navigate in NavigationService.

Can anyone tell me what I`m doing wrong?

For full code see picture below: enter image description here

  • 2
    Possible duplicate of [Using a Button to navigate to another Page in a NavigationWindow](http://stackoverflow.com/questions/803921/using-a-button-to-navigate-to-another-page-in-a-navigationwindow) – ulentini Nov 28 '15 at 11:51

2 Answers2

0

I would suggest using the this pointer and be explicit on your routedeventargs.

    using System.Windows.Navigation;

within:

public partial class MyPage : Page


private void btnNext_Click(object sender, System.Windows.RoutedEventArgs e)
{
    Doelen nextPage = new Doelen();
    NavigationService.Navigate(nextPage);
}
  • I can't seem to add *NavigationService* after *this*, eventhough I've implemented System.Windows.Navigation; –  Nov 28 '15 at 11:24
0
NavigationWindow nw = new NavigationWindow();
nw.Content = new Doelen();
nw.ShowDialog();

or nw.Show():

you may need a nw.Initialze();

paparazzo
  • 44,497
  • 23
  • 105
  • 176