在页面之间传递状态?
我有一个包含两个页面的 Silverlight Windows Phone 7 应用程序。我想在它们之间传递一些重要的状态(数组或结构)。我是否必须遵循将所有内容都打包到查询字符串中的 Web 模型?当所有页面和类都位于同一设备上、同一进程和程序集中时,就没有意义了。
所以问题是:
- 在页面之间导航时,是否有一种按原样传递数据的好方法?
- 页面导航时,源页面的代码隐藏是否可以访问目标页面的代码隐藏(反之亦然)?
- 是否有所有页面都可以引用的共享用户对象(如 ASP 会话)?
或者,有没有办法嵌套 XAML?我可以使用一个模型,其中有一个外部容器页面,可以将不同的内容页面加载到其面板中。
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.
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)?
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您有几个选项:
You have a couple of options:
不,您不必传递查询字符串中的所有内容。只需传递一个 id 并将数据非平凡数据存储在页面之间的隔离存储中。
有一系列关于如何执行此操作的文章 此处
No you don't have to pass everything in a query string. Just pass an id and store the data non-trivial data in isolated storage between pages.
There is a series of articles on how to to do this here