Tag Archives: xaml

Debugging XAML and Prism

The biggest frustration in my Silverlight development is debugging errors in my XAML code.  Since our app uses Prism, there are often three different .xaml files involved in any one change to the app: App.xaml for global styles, Shell.xaml for the main layout and a .xaml file for whatever view I’m working on.  If something goes wrong, knowing what file it’s in is half the battle.

Unfortunately, the errors that Silverlight throws when you have malformed XAML can be pretty obtuse.  Through trial, error and a little intuition I’ve figured out that there are some patterns:

  • If nothing at all renders, the problem is likely in App.xaml.  That gets loaded first, and if something goes wrong then you get bupkus.  Check for syntax errors in App.xaml.
  • If the only thing that renders is the spinny loady thing (I actually don’t know if this is a Silverlight default or a StockTraderRI thing) then I think that usually means the problem is in Shell.xaml.  App.xaml has loaded at this point, but something is keeping the rest of it from going.  Often this can happen if you’re referencing something in App.xaml that’s syntactically valid but semantically nonsense.  Check especially for mis-spelled values inside Setter tags, or badly structured ContentTemplates. Continue reading Debugging XAML and Prism