WPF: Snooping Attached Properties
<Canvas><Button Canvas.Left="{Binding Location.X}"Canvas.Top="{Binding Location.Y"}/></Canvas>
Snooping this application won’t show Canvas.Left and Canvas.Top among the Button’s properties, since they’re not a part of the Button object. If we have a bug in our binding, we won’t be able to find it.
So what do we do? We can set various TraceLevel attributes to save the binding errors to a log, but a quick workaround during debugging is to bind our data, in addition to the attached properties, to the element’s Tag property, a generic object that can bind to anything, and allow us to Snoop the binding – and find out any problems:
<Canvas><Button Canvas.Left="{Binding Location.X}"Canvas.Top="{Binding Location.Y}"Tag="{Binding Location}" /></Canvas>
This allowed me to find out, quickly, that my bug was simple – I had forgotten to make my Location property public, causing the binding to fail silently.