UWP XAML Frame.Navigate to page with parameter

Asked

Viewed 47 times

1

I have two pages and I want to navigate from one to the other. Only 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();
    }
}

1 answer

0


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);
    }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.