A question that came up today during the //learn/ event was how to debug data binding in Windows and Windows Phone projects.Normally I start by checking out the Output window – in most cases any issue with data binding is usually a naming issue, which will result in a bindingexpression path error in the Output window as follows:
Error: BindingExpression path error: ‘test’ property not found on ‘App4.MainViewModel, App4, Version=18.104.22.168, Culture=neutral, PublicKeyToken=null’. BindingExpression: Path=’test’ DataItem=’App4.MainViewModel, App4, Version=22.214.171.124, Culture=neutral, PublicKeyToken=null’; target element is ‘Windows.UI.Xaml.Controls.TextBlock’ (Name=’null’); target property is ‘Text’ (type ‘String’)
I was reminded that Xmlspy is a great tool for diagnosing XAML issues, as well as data binding expressions. I downloaded the latest version and was surprised to see that there is full support for all types of Windows Phone 8.1 applications. The only issue I saw was getting it to attach to Windows Phone applications but this was due to my firewall getting in the way. Here’s how you can check and fix this issue:
- Open the XAML Spy Explorer window (View menu–> Other Windows –> XAML Spy Explorer)
- Click on the “cog” icon in the window toolbar
- Find the “Enable remote debugging” option and set it to Yes. You’ll be prompted to permit elevated privileges (I assume to configure firewall).
Now you should be good to debug your application on the emulator/device. The XAML Spy Explorer window will automatically populate with information about your application
Note that you can debug much more than just XAML, including sensors, storage and package deployment information.