Tip

How to speed up Visual Studio 2008's slow WPF designer

Most developers I know are obsessive about managing their software workspace. When you spend countless hours sitting at your laptop creating software, the last thing you want to do is wait on your tools. From setting up keyboard shortcuts to installing your favorite utilities, you know just how to squeeze every drop of performance from your tools so that you can write code fast and furious. WPF developers are no different. Here are a couple tips to speed up the WPF tools in Visual Studio.

Speeding up the designer

Visual Studio supports a plug-in designer model. The .NET Windows Forms designer is a great example of a designer plug-in: when you open a Windows Forms file in Visual Studio, the IDE determines that the Forms class has an affiliated custom UI designer. The designer is loaded into an IDE tab, your code is parsed and the designer renders your UI. Any changes you make to your form, like dragging a button from the ToolBox to the design surface, causes the designer to update the code in YourForm.designer.cs as well as forcing an update to the UI.

WPF UserControls, Pages and Windows designers work the same way. When you open a XAML file, Visual Studio finds the matching WPF designer and loads your XAML into it. If you use this WPF designer for more than few days, however, you'll begin to realize that it is slow, especially when loading large files.

This is a well-known problem, and the WPF designer team at Microsoft (codenamed Cider) is making good progress toward fixing the problem. In the meantime, they have added a setting that makes it easy to speed things up by disabling the designer's normal WYSIWYG view and using the XAML view instead.

  1. Open the 'Tools-Options' menu.
  2. Select the 'Text Editor-XAML-Miscellaneous' node.
  3. Check the 'Always open documents in full XAML' view checkbox.

always open documents in full XAML view

Change the default XAML editor

The simplest change to make to speed up the loading of XAML files is to forget about using the WPF designer altogether. Instead, set the default editor for XAML files to the XML editor. You still get full IntelliSense support while editing XAML, but the load time for most files is dramatically reduced. Making this change is simple.

  1. Right-click a XAMLfile in the Solution Explorer.
  2. Choose the 'Open With…' menu item.
  3. Select the 'Source Code (Text) Editor' item and click the 'Set as Default' button.

open with XAML

open with XAML text editor

The disadvantage with this approach is that you no longer see the XAML/Designer tabs in the editing window. If you do need to work with the designer, choose the 'View-Open With' menu item, and Visual Studio will open the file in another tab.

XAML designer tabs

Walt has trained thousands of corporate developers during the last 14 years and he travels the world speaking at software conferences, and providing developer training for corporations. He writes for several IT magazines, and worked on books/videos and .NET courses for Microsoft Press. As a Wintellect consultant he is presently focused on the WPF, Surface and Silverlight APIs. Walt is also a Microsoft MVP, WPF Disciple, Silverlight Insider and author of the free Shazzam WPF Shader utility.


This was first published in May 2009

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.