页面之间传递状态? [英] Passing state between pages?

查看:87
本文介绍了页面之间传递状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有两个页面的Silverlight Windows Phone 7应用程序.我想在它们之间传递一些非平凡的状态(数组或结构).我是否必须遵循一个Web模型,其中所有内容都需要打包到查询字符串中?当所有页面和类都位于同一设备上,处于同一进程和程序集中时,这毫无意义.

I have a Silverlight Windows Phone 7 app with two pages. I want to pass some nontrivial state (an array or structs) between them. Do I have to follow a Web model where everything needs to be packed into query string? Makes little sense when all pages and classes are on the same device, within the same process and assembly.

所以问题是:
-在页面之间导航时,是否有按原样传递数据的好方法?
-页面导航时,源页面后面的代码是否可以访问目标页面后面的代码(反之亦然)?
-是否有所有页面都可以引用的共享用户对象(例如ASP会话)?

So the questions are:
- upon navigation between pages, is there a good way to pass data as-is?
- upon page navigation, does code-behind of the source page have access to the code-behind of the destination page (or vice versa)?
- is there any shared user object that all pages can refer to (like an ASP session)?

或者,是否有嵌套XAML的方法?我可以用一个模型来做,其中有一个外部容器页面,可以将不同的内容页面加载到面板上.

Alternatively, is there a way to nest XAML's? I could make do with a model where there's a outer container page that loads different content pages into a panel on it.

推荐答案

您有几个选择:

  1. 按照您的建议使用查询字符串.从Web开发的角度来看这是有道理的,但是我们不在Web开发的角度.
  2. 使用静态变量.这可能是最简单的.只需声明一个具有静态属性的类,就可以通过这种方式共享数据.这种方法唯一需要关注的是线程安全性.
  3. 使用隔离存储.

这篇关于页面之间传递状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆