Silverlight 路由事件和异常

发布于 2024-07-15 18:44:41 字数 333 浏览 3 评论 0原文

我有一个复杂的应用程序,它由一个应用程序组成,其中包含许多模块,每个模块都包含许多视图。 我的观点的行为可能会引发异常。

有时我想在创建它们的视图上处理异常,有时在父模块中,有时在祖父应用程序中。

RoutedEvents 的概念似乎是解决这个问题的明智方法,但我不完全确定如何解决这个问题。

有谁可以分享任何示例或链接来证明我想要实现的目标吗?

谢谢 标记

I have a complex application that consists of an Application, containing many modules, each containing many views. The behaviours of my views may throw exceptions.

Sometimes I want to handle exceptions on the view that created them, sometimes in the parent module, sometimes in the grand-parent application.

The concept of RoutedEvents seems like a sensible way of approaching this problem, but I'm not entirely sure how to go about that.

Does anyone have any examples or links they can share that demonstrate what I am trying to acheive?

Thanks
Mark

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

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

发布评论

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

评论(2

无畏 2024-07-22 18:44:41

尽管 Silverlight 包含 RoutedEventHandler 和 RoutedEventArgs,但不幸的是,桌面 WPF 框架中的“路由事件”概念与此不同。

今天保留它是为了源代码和 API 兼容性,将来也许可以支持它。

这意味着,与此同时,您可能能够做一些额外的工作,并且仍然可以通过

  • 在应用程序级别完成此操作,连接您自己的未处理的异常处理程序代码,也许创建并命名类型“AdvancedExceptionManager”或其他,并在此基础上设计一个简单的 API,以允许事物订阅和处理任何异常并将其冒泡。
  • 例如,在模块级别,使用全局/单例未处理异常处理程序代码,订阅和取消订阅“处理”全局异常,以及取消进一步处理。

如果您需要有关如何进行此操作的更多信息,请告诉我。 了解您的“模块”是如何构建或设计的将有所帮助。

Although Silverlight contains the RoutedEventHandler and RoutedEventArgs, unfortunately the concept of "routed events" as seen in the desktop WPF framework is not the same.

Today it's kept for source and API compatibility, and in the future, maybe it could be supported.

What this means is that, in the meantime, you may be able to do a little extra work and still accomplish this by

  • at the Application level, hooking up your own unhandled exception handler code, perhaps create and name the type "AdvancedExceptionManager" or whatever, and design a simple API on top of that to allow things to subscribe and process any exceptions and bubble it up.
  • at the module level, working with the global/Singleton unhandled exception handler code, subscribe and unsubscribe to "handling" the global exceptions, and canceling further processing, for instance.

Let me know if you need more information on how to go about this. It would help to know how your "modules" are constructed or designed.

生来就爱笑 2024-07-22 18:44:41

您可能对此感兴趣:

“Silverlight 3 的 RoutedEvents 实现,包括 WPF 兼容性”
http://sl3routedevents.codeplex.com/

This might be interesting for you:

"RoutedEvents implementation for Silverlight 3 including WPF compatibility"
http://sl3routedevents.codeplex.com/

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