Workaround for invalid markup problems when developing for Windows Phone

Every time I open up a Windows Phone Project in Visual Studio 2013 I got a lots of  errors in the XAML markup. The designer shows "Invalid markup" and the error list is long. I found a workaround for this:

  1. Open Configuration Manager for your Visual Studio solution
  2. Change platform for the Windows Phone Project to x86
  3. Build the Project and the errors is gone
  4. Open Configuration Manager again and change back to "Any CPU"

After follow above steps it will work until you start Visual Studio again.

4 thoughts on “Workaround for invalid markup problems when developing for Windows Phone

  1. Bob says:

    Something else to consider: If you are instantiating an object in your xaml it must have a parameterless constructor. If your parameterless constructor is doing some other work, (like getting data that doesn’t exist because you are in the designer), add this at the start of your constructor:

    if (DesignerProperties.GetIsInDesignMode(new System.Windows.DependencyObject())) return;
    // Do work.

    This is necessary because the designer does execute your parameterless constructor which may fail in design mode an give you the invalid markup.

    In most cases, you probably noticed that you can still run your app with all of those “Invalid Markup” errors. That’s because the parameterless constructor now gets to do its work and everything falls into place.

    So, regardless of what others are saying, this is not a VS or WPF XAML Parser bug. I ran into this issue today using VS 2015, .Net 4.5.2.

Leave a Reply to Claus Topholt Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.