30

Can we Debug Xaml in WPF? Is there any external tool or VS plugin which can do that?

akjoshi
  • 15,374
  • 13
  • 103
  • 121
sag
  • 387
  • 1
  • 4
  • 14
  • 1
    It depends what you mean by, debug. As Darin said it's a declarative language - it's not code that is run. It's like asking to debug a HTML page: it's not code - the JavaScript is (in XAML's case that would be C# code-behind). If you have a specific problem or error or something to 'debug', ask about that instead. – Kieren Johnstone Jul 01 '10 at 07:10

4 Answers4

25

I've occassionally found these tricks here useful...

http://www.wpftutorial.net/DebugDataBinding.html

...particularly the second one where you use a dummy value converter to break in to the debugger. It's useful for seeing exactly what objects are being bound, etc.

IanR
  • 4,703
  • 3
  • 29
  • 27
  • 3
    A similar post, Check this out for more elobrated details - http://www.beacosta.com/blog/?p=52 – akjoshi Jul 01 '10 at 07:56
21

I don't agree with others that it's not possible to debug XAML, but it's true that there are no powerful tools available for this.

As Mark says in this post - http://markegilbert.wordpress.com/2008/03/15/debugging-xaml/

So, the simple answer is yes, you can debug problems with XAML. The longer, more qualified answer is that while it’s possible, the support isn’t terribly robust yet but should improve with newer dev environments (Visual Studio, Expression Blend, etc.).

Tips on how to debug and learn about WPF(Josh Smith): http://joshsmithonwpf.wordpress.com/2007/03/29/tips-on-how-to-debug-and-learn-about-wpf/

Wayback Link | Get line numbers of XAML issues (Peter Himschoot):

Simply add this to your project file:

<!-- under the <PropertyGroup> tag -->
<XamlDebuggingInformation>true</XamlDebuggingInformation>

Now we at least get line number information on the problem :)

More descriptive XAML exception details (Rob Relyea)

More on XamlParseException (Laurent Bugnion)

  • enter image description here

Wayback Link | XAML Runtime Parsing Exceptions (c/o Erno de Weerd)

  • Image of above blog

Wayback Link | How to debug triggers using Trigger-Tracing(Dan Lamping)

  • Image of above blog

Debugging Dynamic XAML in Silverlight (Julia Lerman)

Just use google/StackOverflow to know how to debug specific XAML issues.

akjoshi
  • 15,374
  • 13
  • 103
  • 121
  • 1
    Debugging Data Bindings in a WPF or Silverlight Application - http://blogs.msdn.com/b/wpfsldesigner/archive/2010/06/30/debugging-data-bindings-in-a-wpf-or-silverlight-application.aspx – akjoshi Jul 05 '10 at 06:45
  • 1
    404 on Get line numbers of XAML issues (Peter Himschoot) – Michel Feinstein May 06 '16 at 01:20
  • @mFeinstein Thanks. I have added the imp. info from that link to answer and a Wayback site link to access the cached post. – akjoshi May 08 '16 at 14:47
  • 1
    @LukášKoten Thanks for heads up. I updated few of them... will try to update others when I get some more time :) – akjoshi Jan 17 '20 at 16:42
-4

XAML is a declarative language and not imperative so I don't see how debugging it could be possible.

Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
-4

No it is not possible.

Ragunathan
  • 2,007
  • 1
  • 14
  • 10