WP8页面跳转传值方法总结
2014-03-03 15:25
435 查看
方法一:通过WEB传参方式进行传参
开始跳转页:
NavigationService.Navigate(new Uri("/Page/MainPage/XXXXPage.xaml?Address="+address,UriKind.RelativeOrAbsolute));
转入页:
//此方法应该在页面的Loaded方法体中实现
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;
开始跳转页:
NavigationService.Navigate(new Uri("/Page/MainPage/XXXXPage.xaml?Address="+address,UriKind.RelativeOrAbsolute));
转入页:
//此方法应该在页面的Loaded方法体中实现
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;
相关文章推荐
- 页面跳转实现方法总结
- html 页面内锚点定位及跳转方法总结
- HTML跳转页面方法总结
- 页面跳转方法总结大全
- js页面跳转方法总结
- 跳转页面的方法总结
- JSP页面跳转方法总结
- 页面跳转3种方法结合倒计时总结
- js跳转页面方法总结
- php开发中的页面跳转方法总结
- jQuery实现页面内锚点平滑跳转特效的方法总结
- 页面跳转的方法总结
- Servlet跳转页面的几种方法总结
- 页面跳转方法总结大全
- PHP 页面跳转到另一个页面的多种方法方法总结
- php开发中的页面跳转方法总结
- response.sendRedirect页面跳转的方法总结——实习第六天
- JSP页面跳转的方法总结
- 总结一些页面常见的跳转方法
- JavaScript/js自动刷新页面方法总结和页面跳转