WP8页面跳转实现参数传递的多种方法
2014-08-22 11:54
531 查看
方法一:通过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;
相关文章推荐
- WP8页面跳转实现参数传递的多种方法
- WP8页面跳转实现参数传递的多种方法(已完善)
- Android Activity中使用Intent实现页面跳转与参数传递的方法
- Android实现页面跳转及传递参数的方法
- Swift - 创建代理协议实现页面间参数传递和方法调用
- Activity中使用Intent实现页面跳转与参数的传递(转)
- .net页面间的参数传递多种方法
- JS实现页面跳转的多种方法及区别
- 利用js方法实现html静态页面间参数传递
- Android 实现页面跳转并传递参数
- Android 实现页面跳转并传递参数
- javascript实现页面之间传递参数的方法
- html静态页面传递参数-利用JavaScript方法实现静态
- asp.net中页面间url参数传递的三种实现方法
- js实现跳转页面的多种方法
- GridView实现超链接列和图片列,跳转页面并传递参数
- asp.net页面间的参数传递多种方法
- html静态页面传递参数-利用JavaScript方法实现静态
- JS实现网页开窗刷新 GeT传递参数成功 远程打开页面失败的解决方法
- 用javascript实现html页面之间的参数传递的四种方法