15

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.

Community
  • 1
  • 1
Daniel Trebbien
  • 38,421
  • 18
  • 121
  • 193

4 Answers4

9

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

Michael Kelley
  • 3,579
  • 4
  • 37
  • 41
6

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.

Tim Heuer
  • 4,301
  • 21
  • 20
2

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

Michael
  • 421
  • 1
  • 6
  • 18
1

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.

GameAlchemist
  • 18,995
  • 7
  • 36
  • 59
  • Finally had a chance to try this out. I right clicked on the Output window and the checkbox menu item named "Exception Messages" was checked, but there was no output when I purposely misspelled the property name. – Daniel Trebbien Jan 07 '12 at 19:32