UWP XAML Frame.Navigate for page with parameter

1

I have two pages and I want to navigate from one to another. But the second page has a parameter that should be received from the first.

...
class MainPage
{
    MainPage()
    {
        InitializaComponent();
    }

    public void ok_buttonClicked(object sender, EventArgs e)
    {
        Frame.Navigate(typeof(SecondPage));
    }
}

class SecondPage
{
    SecondPage(int item)
    {
        InitializaComponent();
    }
}
    
asked by anonymous 04.04.2016 / 17:17

1 answer

0

It would look like this:

class MainPage
{
    MainPage()
    {
        InitializaComponent();
    }

    public void ok_buttonClicked(object sender, EventArgs e)
    {
        var param = "Valor";
        Frame.Navigate(typeof(SecondPage), param);
    }
}

Page 2

class SecondPage
{
    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        Debug.Write(e.Parameter);
    }
}
    
28.01.2017 / 15:04