Windows Phone 8.1 - Page Navigation

前端 未结 4 1680
无人共我
无人共我 2020-12-01 05:11

Coming from Windows Phone 8 I have never thought there will be a lot of changes done to the Windows Phone 8.1 code. Basically I\'m just wondering h

4条回答
  •  南方客
    南方客 (楼主)
    2020-12-01 05:43

    To send multiple parameters: Its quite late to answer but might help someone. You can create a custom class, set your parameters in it and send its object as a parameter to your target page.

    For example. Your custom class:

    public class CustomDataClass
    {
    public string name;
    public string email;
    } 
    
    CustomDataClass myData = new CustomDataClass();
    myData.name = "abc";
    myData.email = "abc@hotmail.com";
    
    Frame.Navigate(typeof(SecondPage), myData);
    

    And then on the target page you can retrieve in OnNavigatedTo function like this:

    protected override void OnNavigatedTo(NavigationEventArgs e)
    {
    CustomDataClass myData2 = e.Parameter as CustomDataClass;
    string name = myData2.name;
    string email = myData2.email;
    }
    

    Hope it helps.

提交回复
热议问题