Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging XAML databinding in Visual Studio 2012

In the Silverlight 5 beta I could debug databinding directly in XAML. Where is this feature in Visual Studio 2012 (RC)? Can I do this with WPF, WinRT and/or Silverlight? If so how? When I set a breakpoint on a binding expression application, I get the message that the breakpoint will not be hit because no source code is associated with this line.

Update:

It works in Visual Studio 2012 (RC) for Silverlight 5 applications but not for WPF applications. Please don't tell me, that this feature does not exist for WPF!

like image 884
bitbonk Avatar asked Jun 01 '12 12:06

bitbonk


People also ask

How do I debug XAML code in Visual Studio?

To debug workflow XAMLOpen a workflow or activity project in Visual Studio. Set a breakpoint on the activity or activities you want to debug as described in How to: Set Breakpoints in Workflows. Right-click the . xaml file that contains your workflow definition and select View Code.

How do I debug WPF application in Visual Studio?

You can use the Live Visual Tree to explore the visual tree of a WPF object and view the WPF dependency properties for the objects in that tree. You can use the WPF Tree Visualizer to explore the visual tree of a WPF object and view the WPF dependency properties for the objects in that tree.


1 Answers

Sorry to tell you but this feature DOES NOT exist in WPF XAML nor does it exist in WinRT XAML. I can't find an official source for WPF, but here is a pretty official one for WinRT (http://social.msdn.microsoft.com/Forums/en-US/toolsforwinapps/thread/fae53937-cb47-45da-b740-49f75f8d36e9/) he insinuates pretty strongly that this was an effort spearheaded purely by the Silverlight team and can possibly be expected in future versions of WPF and WinRT.

So far the best debugging techniques I've seen are as follows:

1) WinRT & WPF: Output Window Using the output window with the proper options enabled, make sure Tools->Options->Debugging->Output Window->Data Binding = "Warning" or something else useful...

enter image description here

2) WinRT & WPF: Use a converter Using a converter and just setting a break point inside the converter. Or you can build/use something similar to how WinRT XAML Toolkit does: http://winrtxamltoolkit.codeplex.com/.../WinRTXamlToolkit.Debugging/Converters/BindingDebugConverter.cs

3) WinRT: Use DebugSettings.BindingFailed

App.Current.DebugSettings.IsBindingTracingEnabled = true;
App.Current.DebugSettings.BindingFailed += (s, e) =>
{
    // debug the failed binding here
};

see: http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.debugsettings.bindingfailed for more information

4) WPF: Use PresentationTraceSources.TraceLevel Attached Property Gives you a verbose output of the binding, see: http://msdn.microsoft.com/en-us/library/system.diagnostics.presentationtracesources.tracelevel.aspx for more information.

I realize this is an older question, but I couldn't find a good source of information for everything XAML, found this answer off a search engine and noticed it was still lacking an answer. It doesn't help that there are technically 3 versions of XAML going by the same moniker. So here's the dump of everything I found while investigating debugging bindings. Enjoy, hope it helps someone... -ck

like image 177
ckozl Avatar answered Oct 31 '22 05:10

ckozl