Well hope you are aware of the Silverlight 5 Beta release announcement today and it's latest features; if not then make sure to have a look at the news sections of C# Corner and my earlier post here. In this post we will discuss XAML binding debugging, a new feature available in Silverlight 5. Be sure that you read my last line carefully; it's XAML Data Binding debugging not XAML debugging.
For any data driven application with declarative data binding, with in XAML, this brand new feature is significant in many ways. Personally I remember most of the time I avoiding the XAML way of binding since it lacked debugging features. Now with Silverlight 5 my previous approach will surely take a back seat and will allow me to consider both ways equally.
Make sure that you have downloaded the latest version of the Silverlight Toolkit SDK. If not then download from here. Also make sure that you are running on Visual Studio SP1.
The XAML Data binding
The example demonstrated here implements basic XAML data binding with the DomainDataSource control; let's look at the XAML binding of one of the controls.
Nothing fancy; simple binding.
The XAML Debugging
SETTING UP BREAKPOINT
As of now the XAML allows us to apply a breakpoint on the Binding syntax only. Once the breakpoint is applied, it hits the breakpoint whenever a push and pull is triggered for that control. The image bellow shows the breakpoint within XAML.
The XAML editor will not allow you to set breakpoint anywhere else other than Binding syntax.
THE DEBUG INFORMATION
Once the breakpoint is set, start the application and wait for the compiler to hit it .
You can find the debug information from Local tab.
The information shows up a BindingState object holding complete binding context information of the control.as in above image , the BindingState value isUpdatingTarget so this way it shows that the binding is pushing data to control.
Going deeper into the debugging information, it shows a complete picture on the nature of data and binding.
Now another interesting fact; in a TwoWay binding scenario once you change the data, for example the FirstName control:
the breakpoint again gets a hit as the binding source is getting updated. And the debug information shows the Binding state as Updating Source status.
and the CurrentItem Information shows up the editing item detail and it's properties.
Hope this article helps you to know the cool new feature of Silverlight 5. Try it and extract information you need to know right from XAML.
Keep commenting and keep your suggestions flowing. More to follow on the Sillverlight 5 Beta new features as I explore .
Download Source Code - Silverlight5_XAMLDebug.zip