方法一:通过WEB传参方式进行传参
开始跳转页:NavigationService.Navigate(new Uri("/Page/MainPage/XXXXPage.xaml?Address="+address,UriKind.RelativeOrAbsolute));转入页://此方法应该在页面的Loaded方法体中实现string address=NavigationContext.QueryString["address"];
判断是否存在:if (NavigationContext.QueryString.ContainsKey("address"))
{
string address=NavigationContext.QueryString["address"];
}
方法二:通过独立存储方式进行传参
开始跳转页:IsolatedStorageSettings iss = IsolatedStorageSettings.ApplicationSettings;iss["ImageSource"] = image.source;NavigationService.Navigate(new Uri("/Page/MainPage/XXXXPage.xaml", UriKind.Relative));转入页:IsolatedStorageSettings iss = IsolatedStorageSettings.ApplicationSettings;image.Source = (BitmapImage)iss["ImageSource"];
方法三:通过PhoneApplicationService来实现传参
开始跳转页:PhoneApplicationService myService = PhoneApplicationService.Current;protected override void OnNavigatedFrom(NavigationEventArgs e){myService.State["address"] = "address"; base.OnNavigatedFrom(e); }转入页:PhoneApplicationService myService = PhoneApplicationService.Current;protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e){object address; if (myService.State.ContainsKey("address")){ if (myService.State.TryGetValue("address", out address)){ string address = address.ToString(); } } base.OnNavigatedTo(e); }
方法四:通过App.xaml进行传参(共享参数)
App.xaml:定义一个或几个用于传参的对象,如public string Address{set;get;}开始跳转页:(Application.Current as App).Address= "address";转入页:string address=(Application.Current as App).Address;
判断是否存在:
if (PhoneApplicationService.Current.State.ContainsKey("address"))
{
string address = PhoneApplicationService.Current.State["address"] as string;
}