views:

57

answers:

3

In general, what are the best practices to debug a Silverlight or WPF application, especially when you get errors with Databinding? Are there free tools available? I am not getting any errors as such, but I am interested in figuring out the approaches that you take as Silverlight and WPF experts.

Thanks!

+1  A: 

Visual Studio's Debug window shows you any binding errors it encounters, and I've also used Snoop for figuring out UI problems before

Rachel
+6  A: 

In Visual Studio, go into
Tools - Options - Debugging - Output Window, and set "Data Binding" to "All".
This is what I use all the time when my Bindings don't work as they're supposed to :)

From the Output window you can then see the hashcode (and alot of other information) of the binding that failed, and then you can use GetHashCode() on any DependencyObject to find the object that's failing (since you likely know where to look this doesn't take to much time).

Also checking the input values of Converters are a great way to go.

Meleak
Thanks much Meleak!
Rahul Soni
+4  A: 

Bea Stollnitz has an excellent post on her blog: How can I debug WPF bindings? I've only needed to use her idea of a debug ValueConverter once, but it made a huge difference.

Robert Rossney
Very nicely written post. Thanks Robert, the link really helped!
Rahul Soni
I haven't yet encountered a binding problem that the method she describes hasn't resolved.
Robert Rossney