I am trying to pass a simple string between pages but I don't know how to.
I created a test app where I click a button, the the value of "a" will pass on the next page (Page1.xaml.cs)
    private void button1_Click(object sender, RoutedEventArgs e)
    {
        string a = "hello";
        Page2 p2 = new Page2();
        NavigationService.Navigate(p2, a);
    }
Now, I want to extract the data from Page1 (Page2.xaml.cs)
    private void NavigationService_LoadCompleted(object sender, NavigationEventArgs e)
    {
        string str = (string)e.ExtraData;
    }
And then subscribing in the constructor (Page2.xaml.cs)
    public Page2()
    {
        InitializeComponent();
        NavigationService.LoadCompleted += NavigationService_LoadCompleted;
    }
However when I ran the program I get an error. Can someone point out what am I missing?
 
     
     
     
    