navigate to another page with an object uwp c# code example

Example: navigate to another page with an object uwp c#

// On the corrent page
public class RestaurantParams
{
    public RestaurantParams(){}
    public string Name { get; set; }
    public string Text { get; set; }
    // ...
}

var parameters = new RestaurantParams();
parameters.Name = "Lorem ipsum";
parameters.Text = "Dolor sit amet.";
// ...

Frame.Navigate(typeof(PageTwo), parameters);


// On the page you want to get to
protected override void OnNavigatedTo(NavigationEventArgs e)
{
    base.OnNavigatedTo(e);

    var parameters = (RestaurantParams)e.Parameter;

    // parameters.Name
    // parameters.Text
    // ...
}

Tags:

Misc Example