Wednesday, November 19, 2008

Visual Studio 2008's bug in it's XAML editor bugged me all morning

All I got to say is "AAAAHHH!"...

I spent the morning trying to figure out why Intellisense fails to work in my XAML files. Life was great, then one day it stopped working. I couldn't figure out why. Googling for solutions came up with nothing.

So, I decided to create a blank XAML file in my project. Guess what? Intellisense worked there. So, I went through starting to recreate my "bad" XAML file. As soon as I added a namespace reference to my own assembly, it broke. In the code snippet below, you'll see the offending line. It's the xmlns:local. Remove that line, Intellisense works, add it and Intellisense breaks. Great!

<Window x:Class="MyProject.Window1"

Now that I knew it was related to that line, a much more targeted google brought up this one Microsoft forum where the issue was discussed, recognized as a bug by MS, and supposed will be fixed in the next Service Pack. Problem was, at the time of writing, the next SP was to be SP1. I've got SP1, but the bug still persists.

So, in light of the stupid bug, this is the workaround I'm using. It's not perfect, but if you use a reference to your local assembly only for a model-view, you can push your model-view off into a resource file then link via a shared dictionary to your actual UI.


<ResourceDictionary xmlns=""
<!-- Your local resources go here.. oh, and Intellisense is broken when editing this file -->

And now the actual window...

<Window x:Class="MyProjects.Window1"

<ResourceDictionary Source="SharedResources.xaml"/>
<!-- Any local resources -->

<!-- Your contents -->

Sometimes you make coding decisions just because you like your IDE too much to give up it's tools...


  1. Hi, Kevin,

    My name is Zhanbo, and I work in Visual Studio WPF Designer team. We are the team that provides XAML intellisense.

    To better understand your issue, will you please send a repro project to me at zhanbos AT Microosft DOT com (Repleace AT and DOT with @ and .)?

    I look forward to hearing from you.


  2. Kev...solution for you: use Swing.


    Cool that you got a Microsoft guy to respond, though :)