15
votes

What techniques are there for debugging issues with data binding in a Windows Metro style application? Are there techniques available like those for WPF and Silverlight applications, described at:

EDIT: I was originally asking about WinRT data binding debugging techniques so that I could troubleshoot the issue described at Metro: Why is binding from XAML to a property defined in code-behind not working?. I eventually found a solution to this issue, but experimenting with the working solution, I did not see any message in the Visual Studio 11 output window when I purposely misspelled the property name so that it would not be found. It also does not appear that PresentationTraceSources is available to WinRT apps.

4

4 Answers

9
votes

Another possible solution:

sealed partial class App : Application
{
    public App()
    {
        this.InitializeComponent();
        this.Suspending += OnSuspending;
        DebugSettings.BindingFailed += OnDebugSettingsOnBindingFailed;
    }

    private void OnDebugSettingsOnBindingFailed(object sender, BindingFailedEventArgs args)
    {
        new MessageDialog(args.Message).ShowAsync();
    }
    ...
}

Original source: http://www.tozon.info/blog/post/2012/07/23/Debugging-WinRTXAML-bindings.aspx

6
votes

If you look at the output window in VS you will see data binding trace messages on errors. You get this automatically for C++ applications and for managed applications you have to turn on unmanaged debugging to see them. This is an area we are looking to improve on, but for now you have the ability to turn them on and see the trace outputs.

2
votes

In VS11 beta, the templated projects offer a way to help debug binding errors.

I wrote it up here http://www.kelvinhammered.com/?p=150

1
votes

I always use immediate window to track binding issues.

Here's what msdn says about it :

In some settings configurations, first-chance exception notifications are displayed in the Immediate window.

To toggle first-chance exception notifications in the Immediate window On the View menu, click Other Windows, and click Output.

Right-click on the text area of the Output window, and select or deselect Exception Messages.

(in fact default setting was ok for me in vs2010)

hope this can help.