Click here to Skip to main content
13,301,664 members (69,455 online)
Click here to Skip to main content


57 bookmarked
Posted 24 Sep 2008

Silverlight 2.0 in Examples: Part 1 - Silverlight Elements: Panels and Controls

, 24 Sep 2008
part 1 of silverlight 2.0 tutorial
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace DatePickerSample
    public partial class App : Application

        public App()
            this.Startup += this.Application_Startup;
            this.Exit += this.Application_Exit;
            this.UnhandledException += this.Application_UnhandledException;


        private void Application_Startup(object sender, StartupEventArgs e)
            this.RootVisual = new Page();

        private void Application_Exit(object sender, EventArgs e)

        private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
            // If the app is running outside of the debugger then report the exception using
            // the browser's exception mechanism. On IE this will display it a yellow alert 
            // icon in the status bar and Firefox will display a script error.
            if (!System.Diagnostics.Debugger.IsAttached)

                // NOTE: This will allow the application to continue running after an exception has been thrown
                // but not handled. 
                // For production applications this error handling should be replaced with something that will 
                // report the error to the website and stop the application.
                e.Handled = true;

                    string errorMsg = e.ExceptionObject.Message + e.ExceptionObject.StackTrace;
                    errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n");

                    System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight 2 Application " + errorMsg + "\");");
                catch (Exception)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Nick Polyak
Architect AWebPros
United States United States
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.171207.1 | Last Updated 24 Sep 2008
Article Copyright 2008 by Nick Polyak
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid