Home > Coding > Responsive XAML editing with ReSharper

Responsive XAML editing with ReSharper

Working with XAML files in Visual Studio can quickly become a pain on medium to large projects. Even with a decent machine, loading and editing XAML documents can feel very sluggish. There are several things that can be done to make the overall experience better.

Loading faster

If you’re never using the visual WPF designer, make sure it never loads. I’m not simply talking about enabling the option “Always open XAML documents in full view” here. Even if that helps by reducing document opening times a bit, some designer components are still loaded, and there is still room for improvement. The simplest way to never load the designer is to right click on any XAML document in the solution explorer, choose “Open with”, select “Source Code (Text) Editor” and click on “Set as default”. There won’t be XAML/Design tabs anymore in the editor and your documents should open fast.

Visual Studio Open With Dialog

Editing faster

Now that your documents are loading fast, you may want to edit them fast as well. In certain cases, the built-in IntelliSense for XAML is just slow, and happens to run on the main thread, making the overall typing experience quite bad. You can see below a dotTrace performance snapshot of five characters being typed inside a {x:Type} markup element, which is where I usually experience extreme sluggishness.

Slow XAML Completion

More than two seconds for the five keystrokes are being spent on completing the current statement. Even considering the overhead added by the profiler, that’s still not a smooth experience since this function runs on the main UI thread. What can we do then? Turn off auto-completion! Don’t worry, we’re going to replace it soon.

If you ever wandered into Visual Studio completion options for various languages, you may have noticed that the checkbox “Auto list members” is disabled for XAML and thus cannot be unchecked. There are registry solutions to disable it, as seen on this Stack Overflow post. However, as strange as it may seem, the call stack is still the same and the slow performance doesn’t disappear even with the auto listing disabled!

In Visual Studio 2010, IntelliSense appears to still be working, even if no completion list is shown. We have to turn it off at the core. Close all Visual Studio instances, then open the registry at HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\VisualStudio\10.0\Languages\Language Services\XAML (don’t forget to remove Wow6432 if you’re not using a 64 bit OS) and change the dword value CodeSense from 1 to 0. You can also use the reg files provided at the bottom of this post to quickly enable or disable XAML IntelliSense in Visual Studio 2010. Be aware that this modification is done at the machine level, and will impact all local users.

In Visual Studio 2012, following the instructions on the Stack Overflow post seems to suffice to disable built-in IntelliSense.

Open Visual Studio: XAML editing should now be fast. But fast without any auto-completion is pretty meaningless. That’s where ReSharper kicks in. In version 6 and the newly released version 7, it provides advanced XAML completion, including data context completion in bindings and other niceties. The downside of this is that it’s currently shown only on demand by using Ctrl+Space. That’s partly why I developed GammaXaml, a ReSharper plugin that improves XAML editing in general, and exposes ReSharper on demand completion as automatic, on typing completion. Simply install the plugin and you’re done. You can now enjoy a pretty fluid editing experience.

Attachment : ChangeXamlIntelliSense.zip

  1. Robert Neumann
    2013/02/13 17:42 | #1

    Excellent! You saved me lots of time, ReSharper 7 + Visual Studio 2010 was crawling along in XAML editor… Thank you very much! :-)

  1. August 18th, 2014 at 23:30 | #1

Leave a Reply