windows phone 8 使用页面传对象的方式 实现页面间的多值传递
来源:互联网 发布:拉什福德数据 编辑:程序博客网 时间:2024/06/05 01:11
在做windows phone 开发的时候,会经常碰到页面间之间的跳转和传递数据,如果传递的值不多,只有两三个,我们通常使用NavigationService.Navigate(new Uri("页面名? Name=“”&ID=“ ”, UriKind.Relative));
要是碰到要传递多个值的时候,你就要写很多很多的&符号连接。这样不好看。
这里我写一种更好的方法---传递对象
思路
定义一个类,类里面包含你所有需要传递的字段,然后在App.xaml.cs 申明这个类的对象,最后使用这个对象,
向这个对象中添加字段。
做法
第一步:
定义一个公共访问类
public class GoodHelper { public string GoodName { get; set; } public int GoodPrice { get; set; }}
第二步:在App.xaml.cs 中申明这个类的对象
public static GoodHelper goodhelper { get; set; }
第三步:在页面响应事件中向这个对象中的字段赋值
private void button1_click(object sender, System.Windows.Input.GestureEventArgs e) { App.goodhelper = new GoodHelper { GoodName="123", GoodPrice="4576" }; this.NavigationService.Navigate(new Uri("/market/DetailGood.xaml", UriKind.Relative)); }
最后在跳转到的页面中获取对象的值
if (App.goodhelper != null) { string GoodName = App.goodhelper.GoodName; int GoodPrice = App.goodhelper.GoodPrice; }
0 0
- windows phone 8 使用页面传对象的方式 实现页面间的多值传递
- windows phone 页面之间传值方式
- Windows phone 7 页面之间参数的传递
- windows phone:页面间传递数据
- Windows phone 8 页面间数据共享方式
- 页面间传递数据的方式,使用Event
- Windows Phone 系列- Simple MVVM Navigation 页面导航的实现
- Window phone 页面间值传递
- Servlet页面间对象传递的方法
- Windows Phone 页面之间参数传递方法
- windows phone关于页面跳转的总结
- windows phone页面的简单导航操作
- 页面间值传递的几种方式
- 使用EventBus实现页面间数据的传递
- html中不使用内置对象的方式实现多个页面用同一变量
- 不同页面之间实现参数传递的几种方式
- windows phone 页面传值(7)
- 页面间的传递
- [转]用ASP编程的思想用.Net编写留言本
- HDU 3081 Marriage Match II 二分+最大流
- 感谢您注册CSDN社区,您只需要点击下面链接,激活您的帐户,您便可以享受CSDN各项服务。
- window.opener 与 window.dialogArguments的用法
- const char* and char *
- windows phone 8 使用页面传对象的方式 实现页面间的多值传递
- UIScrollerView加载大量数据内存爆满的问题
- 往事如烟可否随风去?
- 上树建站教程:新手单页网站制作教程上集
- error页面
- 【Google Chart Tools: Infographics】谷歌图表工具:信息图表
- Java线程:线程状态的转换
- C++ LINK:fatal
- ArcGIS For Server10.1新特性之-服务器端打印服务及前端调用