Tuesday, 24 April 2012

Silverlight Glimpse

Silverlight Glimpse

Silverlight Glimpse helps developers track down binding errors, highlight validation errors and unhandled exceptions in their application.

A small Silverlight Glimpse window sits on top of your Silverlight application displaying real time error counts for bindings, validations and exceptions as your application hits it's bugs.

To view the detail of each individual error just click the expand button on the window to show all the relevant information.

This debugging tool written in C# and compiles to a dll which can be referenced from your Silverlight application.

It’s an open source project, written C# and available on CodePlex:  https://silverlightglimpse.codeplex.com/


This tool is based upon the original Glimpse for Silverlight 3 written in VB.NET by Karl Shifflett.  For those that don’t know him, he’s a WPF disciple and one of the top guys in the XAML!

His blog post in 2009 on the original project can be found here:


Adding Silverlight Glimpse to your App

Simply wrap the setting of your RootVisual with the following code:

private void Application_Startup(object sender, StartupEventArgs e)
this.RootVisual = new MainPage();
catch (Exception ex)
Glimpse.Service.DisplayLoadFailure(this, ex);

On Start up

When your application loads Silverlight Glimpse will add a little window in the top left hand corner of the screen.


Exception on Application Start up

If an exception occurs during the loading of your root visual page, Glimpse will take over and display the relevant information for you to troubleshoot.


User Interface

The three numbers relate to the three different types of errors that Silverlight Glimpse can detect:


Expanded View

When the user clicks on the Expand button you get to see the detail of the binding errors, validation errors and unhandled exceptions.

There is also a debug tab which I’ll explain shortly.


In this example, the Silverlight screen had one binding in the tbDescription textbox as the Path was set to DescriptionWithATypeo.  This helps the developer track down and fix the bug.


Polling vs Real Time

The validation errors and unhandled exceptions are updated in real time.

Unfortunately, due to the Silverlight and security restrictions I wasn’t able to hook into events for the binding errors (which are also output to the Output window in Visual Studio).

Therefore Silverlight Glimpse polls the root visual element and all it’s children to pick up the broken bindings.  The refresh rate defaults to five seconds but you can override that value.

The debug tab shows the length of time it took to traverse the VisualTree to locate the broken bindings.


Validation Errors

This user has started entering data which has so far failed on all four of the controls.  Silverlight Glimpse detects these validations based on controls using NotifyOnValidationError:

<TextBox Text="{Binding Username,
NotifyOnValidationError=True}" />

This can help developers that are working on custom styles and may not have visual feedback available.


Unhandled Exceptions

If your application fails to handle any exceptions these will be detected and displayed in real time.



Current Known Restrictions

Binding errors and validation errors are not currently being detected in Child Windows (part of the Silverlight SDK).  Exceptions will still be tracked.

Open Source on CodePlex



  1. Any thought to porting this to Win8?

  2. Hi Fallon, sure I'll update for Win8 once it's released. The dev preview had lots of xaml bugs that put me off for now as I dont have a touch machine.

  3. Thank you, thank you, thank you!!!!

    Finally, I found what I was looking for. I can not believe MS hasn't provided something like this with Silverlight itself. They are nuts if they think they want me to find out the binding errors by looking at Output Window in Visual Studio.

    Man, if you are in NYC, I owe you a beer.

    Also, I have few ideas on how this could be improved. Will contribute on CodePlex.

  4. That's great Yogi, I'll see you on CodePlex!

  5. awesome post Yogi, i guess your post is much informative for newbi in silverlight
    Very good presentation... Keep it up

  6. How can we set the startup position of the floating window?