WPF/E: Running side-by-side with WPF Designer (a.k.a "Cider")

There are two main ways to develop WPF/E within Visual Studio 2005 - one is to edit the XAML in the XML Editor, and the other is to use Cider, the XAML WPF designer.  There are pros and cons to each approach, and some configuration for each.

Using Cider
cider Cider is the Visual Studio designer for WPF and XAML and is shown to the right.  It is available in CTP (there are no plans for an RTM version for VS 2005).  You can edit in a design view or a XAML view and they are synchronised.

This sounds great.  The only problem is that you have to be very careful to limit yourself to the WPF/E subset of XAML.  Cider targets the full set of XAML and WPF, so you may find that you end up developing something that doesn't work in WPF/E.  If you've developed anything with WPF/E, you'll know that the runtime errors are not particularly informative and so you might not want to go down this route.

Also, for Cider to work your XAML document needs to be in the namespace http://schemas.microsoft.com/winfx/2006/xaml/presentation. This isn't the WPF/E namespace.



Using the XML Editor
wpfe intellisense I was very disappointed when I'd installed the WPF/E SDK and Visual Studio didn't give me Intellisense on my WPF/E XAML.  It turns out that this isn't very difficult to enable.  All you have to do is copy the file "wpfe.xsd" from the WPF/E SDK Schema directory into the Visual Studio schema directory.  In my case, I copied the file from

C:\Program Files\Microsoft SDKs\WPFE\Help\XSD 
C:\Program Files\Microsoft Visual Studio 8\Xml\Schemas

These are the default directories so your system is likely to be the same.

It's worth noting that the default namespace on your XAML document needs to be http://schemas.microsoft.com/client/2007 for Visual Studio to associate the schema.  This is the proper WPF/E namespace.


Getting Visual Studio to Use the XML Editor
If you have installed Cider, you will find that Visual Studio wants to open all XAML documents using this and not using the XML editor.  If you do want to use the XML Editor, you need to inform Visual Studio of this.  To open XAML files in the XML editor by default you can go to the Tools / Options window and under Text Editor / File Extensions set .xaml files to open in the XML Editor.  A screenshot of this is below.  If you then want to open a XAML file in Cider, you will need to right-click from the Solution Explorer and choose "Open With ...".

And this is the other way of getting XAML files to open in the XML Editor (i.e. without modifying your options).  You can always right-click on your XAML file and go through the "Open With ..." dialog.  Personally, I prefer just to double-click.


UPDATE: WPF/E is now better known as Silverlight.  An unusual example of Microsoft changing from a clunky codename to a cool product name!

December 8 2006

WPF/E: Only HTTP locations work by default

Trying out some of the WPF/E samples, I noticed some rather odd behaviour.  I loaded a sample directly off my file system and was rewarded with a blank security and a notice that Internet Explorer was blocking some active content.  I then setup a virtual directory on my local IIS instance and everything was fine.  You can see the two renderings here:

border-right: 0px" title="silverlight-apps" src="http://www.sharpfellows.com/image.axd?picture=silverlight-apps_thumb.jpg" border="0" alt="silverlight-apps" width="429" height="281" />

settings1 Now this sounded to me like a security problem, and that's exactly what it is.  When you load the page via HTTP then Internet Explorer will work out which Internet Zone you are in (Intranet, Trusted Sites, Internet, etc) and the configured security.  Below to the right is a screenshot of the default WPF/E security settings and you can see that it will run content, even for the Internet zone.

settings3 However these settings only applies to pages loaded via HTTP.  If you are loading some HTML directly from your file system (like I was) then there are some different security settings.  The defaults are shown below and you'll notice that they prohibit active content, which includes WPF/E XAML files.

So strangely enough, as far as XAML and WPF/E go, your local file system is a more restrictive location than the Internet.  Work that out if you can!

UPDATE: WPF/E is now better known as Silverlight.  An unusual example of Microsoft changing from a clunky codename to a cool product name!

December 5 2006

WPF/E: Setting up your workstation for development

So you've installed the WPF/E runtime and played with a few samples.  You've probably also installed the WPF/E SDK and opened up some of the sample source code.  What next?  Write your own WPF/E code, of course! 

Adam Kinney has posted a video on Channel 9 about Getting Started with WPF/E. It's worth a listen (I say listen because the code on his screen is illegible, but it's interesting anyway).  In this video he opens up a WPF/E project template and uses that as a starting point.  So where is this template and how can you get it?  Well, there's a hard way and an easy way to get it ...

The Hard Way

silverlight-template-menu If you've installed the WPF/E SDK there is a link in there's a link in your Start Menu which should look like the image to the right.  This links to an installer which will get the WPF/E project template loaded.

Not too hard, you think?  Well it's not that simple.

This installer requires some additional Visual Studio bits.  Specifically you need to download and install the following:

This is a bit of a bother as it will affect your Visual Studio installation outside of your WPF/E development.  But if you liked the VS2003 web projects and you miss them then go ahead.

The Easy Way

Project templates are really just specially constructed zip files and Visual Studio 2005 has a special folder where you can add your own.  This is configured on Tools / Options / Projects and Solutions, but it defaults to "[My Documents]\Visual Studio 2005\Templates\ProjectTemplates".  So if you go to this folder, open up the "Visual C#" folder (or whichever sub-folder you prefer) you can copy in the project template which I've attached to this post.  Then you'll get the WPF/E template showing up in your New Project window as follows without installing anything else:



EDIT [2006-12-06]: I've modified the attached template for:

EDIT [2006-12-08]: I modified the namespace back to http://schemas.microsoft.com/client/2007.  Once you've copied the wpfe.xsd file correctly, Visual Studio will then give you Intellisense.  See my next post for more info.

December 5 2006

WPF/E: First CTP is now available for download

The Dec 2006 CTP of WPF/E is now available for download.  If you're interested in this, you'll want to check out the following links:

And lastly, you can always check my own summary of what WPF/E has to offer (written pre-release).

UPDATE: WPF/E is now better known as Silverlight.  An unusual example of Microsoft changing from a clunky codename to a cool product name!

December 4 2006
Newer Posts Older Posts