none
How to debug data binding issues?

    Question

  • I've got a post over here (http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/b1ddb46f-eb2d-4cf8-acdf-e790f5b534300) where I'm having issues with my data binding when I have a semantic zoom grouped grid view and then I do an item click so I can get to my item detail page and allow the user to make changes.  Those changes aren't appearing back in my grouped grid view. 

    I decided to create a new thread specifically to ask how to debug issues like this.  I've found other forum posts that indicate you can add the following attribute diag:PresentationTraceSources.TraceLevel="High" and you'll get extra info the Output window. Unfortunately, that doesn't appear to be available in WinRT.

    Sunday, June 10, 2012 4:45 PM

Answers

  • @Lisa19,

    In CP, go to debug settings in the project and turn on Mixed Mode (Native) debugging, which will then display messages in the output window if it is unable to bind. Unfortunately the messages that are available are nowhere near as good as the WPF tracing.

    ...Stefan

    Tuesday, June 12, 2012 12:33 AM
  • @Lisa - please move off CP as soon as you can.  There are enough breaking changes to be concerned about that you should migrate to the release preview.  BindingFailed is only in the RP.  As Stefan suggests if you turn on mixed-mode debugging you will see these trace errors in CP.

    Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)

    Tuesday, June 12, 2012 1:30 AM

All replies

  • Wire up an event listener to DebugSettings.BindingFailed and you can output the message to the window.  This actually should be happening for you if you are using one of the templates as a starting point and in DEBUG mode.

    Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)

    Monday, June 11, 2012 2:11 AM
  • I started out with the Semantic zoom and grouped grid view example and am running in Debug mode.  I don't see anything other than assemblies being loaded or skipped in the output window.  I also set my WPF Trace Setting to verbose thinking that might help. 

    I'm stuck on how to actually perform what you suggested.  Could you provide an example or a reference link?  The documentation at http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.bindingfailedeventhandler.aspx wasn't clear to me. 

    Monday, June 11, 2012 9:46 AM
  • @Lisa19 - are you using WPF or Metro?  This event is only for Metro.  In your App.Xaml.cs you can add an event handler for DebugSettings.BindingFailed and then inspect the args.  Something like:

    public App()
            {
                this.InitializeComponent();
                this.Suspending += OnSuspending;
                DebugSettings.BindingFailed += DebugSettings_BindingFailed;
            }
            void DebugSettings_BindingFailed(object sender, BindingFailedEventArgs e)
            {
                Debug.WriteLine(e.Message);
            }


    Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)

    Monday, June 11, 2012 4:19 PM
  • I'm using Metro.  I'll give this a try and reply back.
    Monday, June 11, 2012 4:47 PM
  • @Tim - I added this but can't get it compile.  I've looked at the ObjectBrowser for Windows.UI.Xaml.DebugSettings and don't see the event handler nor do I see it at Windows.UI.Xaml.  I'm still using Windows 8 CP. 

    public App()
            {
                InitializeComponent();
                this.Suspending += new SuspendingEventHandler(OnSuspending);
                //DebugSettings_BindingFailed += DebugSettings_BindingFailed;
                this.DebugSettings_BindingFailed += new BindingFailedEventHandler(DebugSettings_BindingFailed);
            }
    
            void DebugSettings_BindingFailed(object sender, BindingFailedEventArgs e)
            {
                Debug.WriteLine(e.Message);
            }

    Monday, June 11, 2012 11:00 PM
  • @Lisa19,

    In CP, go to debug settings in the project and turn on Mixed Mode (Native) debugging, which will then display messages in the output window if it is unable to bind. Unfortunately the messages that are available are nowhere near as good as the WPF tracing.

    ...Stefan

    Tuesday, June 12, 2012 12:33 AM
  • @Lisa - please move off CP as soon as you can.  There are enough breaking changes to be concerned about that you should migrate to the release preview.  BindingFailed is only in the RP.  As Stefan suggests if you turn on mixed-mode debugging you will see these trace errors in CP.

    Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)

    Tuesday, June 12, 2012 1:30 AM
  • Hello, Tim. I'm using Windows 8 RP & Visual Studio ultimate 2012 RC V11.0.50522.1. I can't use DebugSettings.BindingFailed event. What can I do to fix this?
    Saturday, July 07, 2012 9:59 AM
  • @tragvar - what do you mean you can't use that event?

    Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)

    Saturday, July 07, 2012 3:58 PM
  • I've got this error: 'Windows.UI.Xaml.DebugSettings' does not contain a definition for 'BindingFailed' and no extension method 'BindingFailed' accepting a first argument of type 'Windows.UI.Xaml.DebugSettings' could be found

    I could not find the BindingFailed event.

    Sunday, July 08, 2012 9:17 AM
  • @travgar - are you on the Release Preview or earlier?  This was only introduced on the Release Preview, so if you aren't on that yet, you would need to use that.  My assumption is that it looks like you may have an SDK mismatch.  Performing a repair on VS installation might help here.

    Tim Heuer | Program Manager, XAML | http://timheuer.com/blog | @timheuer

    (if my post has answered your question, please consider using the 'mark as answer' feature in the forums to help others)

    Tuesday, July 10, 2012 5:31 PM
  • Reinstalling helped the third time) Thank you very much!

    P.S. Excuse Me my English.

    Tuesday, July 10, 2012 9:48 PM