Silverlight Error handling at user control level

When you are developing user control in Silverlight you might want to handle all errors for that user control at one place. For handling all errors at one place you have to subscribe to event
UnhandledException of the App class
Code
  public partial class Page : UserControl
{

public Page()

{

InitializeComponent();

App.Current.UnhandledException += new EventHandler(Current_UnhandledException);



}



void Current_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)

{

//handle exception here. like showing a message box

}



}


1 comments:

mehta said...

Nice Stuff!

Commendable Blog Indeed!

Dear Blogger, need your valuable feedback for:

www.octandigital.com

Regards,
Mehta