2

I want to navigate from one page to another.
If my destination page constructor is defined like ,

    public Bills()
    {
        this.InitializeComponent();
    }

For normal navigation I am using

Frame.Navigate(typeof(Billing.Bills));

and its working fine. suppose if my destination page constructor is containing some parameters like ,

    public Bills(string strBillType, string strExchangeAmount, RootObject objRoot, string strPaymentType)
    {
        this.InitializeComponent();
    }

in above situation how can I navigate to the destination page?.

Sagar
  • 371
  • 9
  • 26

2 Answers2

7

You need to use overload method Navigate(Type sourcePageType, System.Object parameter)

Create you class for parameters:

    public class BillParameters
    {
        //your properties
        public BillParameters(string strBillType, string strExchangeAmount, RootObject objRoot, string strPaymentType)
        {

        }
    }

Pass your parameters:

    var parameters = new BillParameters(strBillType, strExchangeAmount, objRoot, strPaymentType);
    Frame.Navigate(typeof(Billing.Bills), parameters);

and retrive on your destination page

protected override async void OnNavigatedTo(NavigationEventArgs e)
{
    var parameters = e.Parameter as BillParameters;
}
Andrii Krupka
  • 4,276
  • 3
  • 20
  • 41
3

You can't. If you need to send a value to your page, use the overload of Frame.Navigate:

Frame.Navigate(typeof(Billing.Bills), parameter)

You can then retrieve the value of the parameter from your page:

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    // Read e.Parameter to retrieve the parameter
}
Kevin Gosse
  • 38,392
  • 3
  • 78
  • 94