参数在Windows Phone中的XAML之间传递

时间:2013-08-01 17:49:48

标签: c# windows-phone-7

有3个xaml页面,其中2个用不同的参数调用第三页。如何在第三页中写入onNavigatedTo()?

使用NavigationService.Navigate(new Uri("/third.xaml?paramter=xxxx", UriKind.Relative));

1 个答案:

答案 0 :(得分:0)

http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff626521(v=vs.105).aspx借用并修改此代码。

protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
    base.OnNavigatedTo(e);

    string msg = "";

    if (NavigationContext.QueryString.TryGetValue("parameter", out msg))
       // now your parameter is in the msg variable, and you could do stuff here.

    }