wp8.0开发时传参数的一种方法
来源:互联网 发布:数据挖掘分析 编辑:程序博客网 时间:2024/05/17 01:32
wp开发时,页面之间传递参数好像只支持字符串传递。那如果是想传递一个类应该怎么办呢。可以定义一个“全局类”来解决这个问题。代码如下
public sealed class NavigationItem { #region [Fields] private static NavigationItem navigationItem = null; private Object item = null; #endregion #region [Constructor] private NavigationItem() { } #endregion #region [Singleton] public static NavigationItem Instance { get { return navigationItem ?? (navigationItem = new NavigationItem()); } } #endregion #region [Public functions] public void SetNavigationItem(Object navItem) { item = navItem; } public Object GetNavigationItem() { return item; } #endregion }
有了这样一个类,应用中所有需要页面间传递参数处都可以调用NavigationItem类来解决
离开页面时:
NavigationItem.Instance.SetNavigationItem(item.SelectedItem); if (this.NavigationService.CanGoBack) { this.NavigationService.GoBack(); }
加载页面时:
var obj=NavigationItem.Instance.GetNavigationItem()
即可解决。由于item是object类型,适用于传递各种参数。
- wp8.0开发时传参数的一种方法
- WP8页面跳转实现参数传递的多种方法
- WP8页面跳转实现参数传递的多种方法
- WP8.0 开发 环境搭建
- WP8页面跳转实现参数传递的多种方法(已完善)
- AngularJS的一种参数传递方法
- 一种读取.properties配置文件参数的方法
- WP8开发
- 开发时解决跨域常用的一种方法
- wp8开发时模拟器无法联网解决方法
- WP8页面跳转传值方法总结
- DLL开发及调用的一种方法
- 一种软件开发的方法【原创】
- 开发DSP硬件驱动程序的一种方法
- 开发DSP硬件驱动程序的一种方法
- 一种使用JDK开发WebService的方法
- 一种绝对提高开发水平的方法
- 一种通过函数指针调用未确定原型的函数时参数传递的方法
- no installed service named "apache2.2"
- Java 数据类型
- hdu 3065 病毒侵袭持续中 ac_automaton
- 运煤智力题
- xml学习(4) 创建xml 文件
- wp8.0开发时传参数的一种方法
- jQuery笔记
- iOS的主要框架介绍
- Codeforces Round #214div2题解
- 泛泰A820L(高通MSM8660主cpu)的乐蛙patchrom (基于CM10 4.1内核)发布
- IOS CoreText.framework --- 基本用法
- win7下开启wifi热点共享网络的方法
- iOS常用动画
- 【开博第一文】一个新的开始