views:

240

answers:

2

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

+1  A: 

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.

Jeff Wilcox
+1  A: 

This might be interesting for you:

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

Patrick