Silverlight 3.0应用程序中的View之间如何通信?

发布于 2024-08-14 15:27:06 字数 132 浏览 2 评论 0原文

我正在基于 Silverlight 导航应用程序模板构建 Silverlight 3.0 应用程序。我遇到的一个障碍是页面之间的通信。例如,我在一个页面中,我想启动另一个页面并向其发送一些数据。我不知道如何做到这一点。

有什么想法吗?

I am building a Silverlight 3.0 app based on the Silverlight Navigation Application template. One road block I ran into is communicating between the Pages. For instance, I am in one Page, and I want to kick off another page and send it some data. I am at a loss as to how to do this.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

_畞蕅 2024-08-21 15:27:06

您有 2 个选项

  1. 使用发布/订阅模式,我以前没有使用过这个,但它在某些情况下很有用,但我认为它不能解决您的问题。
  2. 使用请求参数,基本上当你导航到新视图时,像这样调用它

    NavigationService.Navigate(new Uri("/HomePage.xaml?HomePageId=12", UriKind.Relative));

您可以在其中添加一些 string.format 以使其更整洁,但您明白了,然后在新视图上,在页面上使用 string queryParam = HtmlPage.Document.QueryString["HomePageId"]; load 获取您要显示的信息的 Id。

应该可以做到这一点。

You have 2 options

  1. Use Publish/Subscribe pattern, i havent used this before, but it is useful in certain cases, i dont think it would solve ur problem though.
  2. Use Request parameters, basically when you navigate to the new view, call it like so

    NavigationService.Navigate(new Uri("/HomePage.xaml?HomePageId=12", UriKind.Relative));

You could slap some string.format in there to make it neater, but you get the idea, then on the new View, use string queryParam = HtmlPage.Document.QueryString["HomePageId"]; on page load to get the Id of the information you wish to display.

That should do it.

风追烟花雨 2024-08-21 15:27:06

我找到了一个有效的解决方案,并且不涉及太多复杂性。我正在使用 LocalMessageSender 和 LocalMessageReceiver 对象。这些对象的最初目的是让同一网页上的 2 个 silverlight 应用程序相互通信,但它也同样适合让 2 个视图相互通信。

用法非常简单。请参阅此 使用示例

I've found an effective solution that does not involve too much complexity. I am using the LocalMessageSender and LocalMessageReceiver objects. The original purpose of these objects are to have 2 silverlight apps on the same web page talk to each, but it's just as good at having 2 views talk to each other.

The usage is really straight-forward. See this example for usage.

初与友歌 2024-08-21 15:27:06

Jesse Liberty 有一篇出色的博客文章,内容仅涉及这。我自己在多页 Silverlight 应用程序中使用了其中描述的技术。

我不确定您是否可以将其与 Silverlight 导航应用程序模板一起应用。

Jesse Liberty has an excellent blog post about just this. I use the techniques described there myself in a multi page Silverlight application.

I'm not sure though whether you can apply this with the Silverlight Navigation Application template.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文