WrapPanel and DockPanel on Windows Phone 7

Posted: June 21, 2010 in .NET, C#, Silverlight, Windows Phone 7
Tags: , , ,

After reading about various ways of using the Silverlight Toolkit (http://silverlight.codeplex.com/) for Windows Phone 7 development, I gave up and tried a different approach.

I am using Windows Phone Developer Tools CTP – April Refresh, which you can download here: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=cabcd5ed-7dfc-4731-9d7e-3220603cad14

Instead of including Silverlight Toolkit dlls in my Windows Phone 7 Silverlight project, I included only specific source files that I needed. It worked without too much trouble, so unless you need a bunch of controls from the Silverlight Toolkit, I would recommend this simple approach for the DockPanel and WrapPanel controls. I suspect that it will also work for other simple controls.

1. Add a new class-library project to your Windows Phone 7 solution.

2. Add a reference to Microsoft.Phone.

Controls. Your reference list should now include the following: Microsoft.Phone.Controls, mscorlib, system, System.Core, System.Net, System.Windows, and System.Xml. Not all of those may be needed, but they were included by default.

3. Go to http://silverlight.codeplex.com, then switch to the Download tab. At the right, you’ll see a box called Other Downloads. Find the Silverlight 3 Toolkit November 2009 Stable release. Download and install it. (I did not try the April 2010 release because I had been told that not all Silverlight 4 classes will work for Windows Phone 7. Let me know if you succeed with the April 2010 release for Silverlight 4.)

4. Find the source code that you just installed. On my Vista system, I found it here: C:\Program Files\Microsoft SDKs\Silverlight\v3.0\Toolkit\Nov09\Source.

5. Drag/drop the following source files to your newly created class-library project: Dock.cs, DockPanel.cs, LengthConverter.cs, NumericExtensions.cs, OrientedSize.cs, TypeConverters.cs, and WrapPanel.cs.

6. Also drag Resources.Designer.cs and Resources.resx from the Controls.Toolkit\Properties project to your new project. Once they are in your project, drag/drop them into the Properties sub-folder of your project. In that sub-folder, you should now see three files: AssemblyInfo.cs, Resources.Designer.cs, and Resources.resx.

7. Build it. If it all went well, include this project with any of your other projects that need DockPanel or WrapPanel.

8. Please tell me if these steps worked for you!


Dale Barnard

  1. can download ready made library from http://www.geekchamp.com/articles/using-dockpanel-in-wp7
    mind you the usage sample shown in the article there is wrong, a user has commented there with the correct XAML for the sample layout

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 )

Google+ photo

You are commenting using your Google+ 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