Home > Silverlight 3 > Namespaces in Expression Blend 3: ‘d’ and ‘mc’

Namespaces in Expression Blend 3: ‘d’ and ‘mc’

I have been using the (brilliant I might add) Expression Blend 3 environment for a while now to mock up some WPF but mainly Silverlight 3 applications. This is a blessing for one simple reason which is that Visual Studio 2008 has NO support for a design view of the Silverlight 3 UI layout. A nice syntax highlighted intellisense code view is all you get. I never used Silverlight 2 (and only jumped in from version 3) but I gather there was some support in Visual Studio 2008 but this could be a little patchy at times, so it seems Microsoft have skipped design view visual layout support for Silverlight 3 in VS 2008 in favour of focussing on VS 2010.

I tend to mock up all of my layouts in Blend 3 now and do some XAML tweaking back in VS 2008 when adding the C# to the code-behind files. I know you can now add C# code to Blend 3 but it is not really something I would seriously use very often. A very common scenario is that VS and Blend are open at the same time on the same project which seems to work reasonably well (dual screen monitor set-up helps!).

Anyway, all the time I have been using Blend 3 I have noticed, but largely ignored, the xmlns:d and xmlns:mc namespaces and the couple of additional UserControl tag attributes that appear automatically courtesy of Blend 3 such as mc:Ignorable="d" and d:DesignWidth="649" d:DesignHeight="460". These did not appear when starting projects in VS 2008 and adding simple XAML so they used to be a bit annoying when I began to use Blend 3 to mock up UI layouts (mainly as I did not know really what they were for and how they were affecting my UI).

It was only yesterday that it became clear that they really did have a practical usage after all. They in fact do not actively alter the UI layout at all at runtime, and affect only the design view. I happened to want to create a Silverlight application that consumed the whole available browser window, and achieved this by placing a Canvas control inside a Grid control with all the widths set to auto and Stretch mode. In design view I could not see any layout! This was because everything of course was collapsed as it had no specific width or height set. However if you click the UserControl object in the ‘Objects and Timeline’ panel there appears a little blue triangle at the bottom right of the UI layout. Click and drag this to see the containers and to add/edit as required BUT without having to specify a width and height if you need auto settings (as I did). This little trick is very helpful, but you must have the namespaces above to make it work.

In fact in one of the projects I deleted the references in XAML but then needed to increase the design time only view layout. Blend only added back in the namespaces and the design width and height and I had a build error. This was annoying as it looked like everything was there that I needed! But the thing that was missing was the mc:Ignorable="d" attribute! Not a mistake I will be making again! ;)

Advertisement
Categories: Silverlight 3 Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.