Click here to Skip to main content
14,365,424 members

d:DesignInstance, d:DesignData in Visual Studio 2010 Beta2

Rate this:
4.20 (2 votes)
Please Sign up or sign in to vote.
4.20 (2 votes)
28 Oct 2009CPOL
d:DesignInstance, d:DesignData in Visual Studio 2010 Beta2

The WPF and Silverlight Designer for Visual Studio 2010 share several new design time (d:) properties and design time MarkupExtensions with Expression Blend 3 that provide necessary information for the WPF and Silverlight Designer to deliver a great editing experience.

I have explained the d:DesignData MarkupExtension in detail in this blog post: Visual Studio 2010 Beta2 Sample Data Project Templates.

In this post, I’ll cover the d:DataContext property and the d:DesignInstance MarkupExtension.


d:DataContext gives developers the ability to set a design time d:DataContext that is separate and independent of the run-time DataContext property.

This feature solves the problem of developers wanting to set their DataContext programmatically but also wanting design time data.

All d: properties are ignored during compilation and are not part of any run-time assemblies.


Purpose: Provides a design time shape to the d:DataContext its applied to.

Example: In the below snippet, the Person class is the shape provided by d:DesignInstance to the Grid’s d:DataContext.

<Grid d:DataContext="{d:DesignInstance local:Person}">

Note: In the above example, the Person class is actually a faux type (fake or substitute type). This faux type enables types that are not creatable to be created and their properties exposed as a shape. See the below section on creating creatable types.

Usage: So, now that the d:DataContext has shape, what can I do with it?

The shape is used by the new Binding Builder to expose the properties of the type in d:DataContext. You can see in the below image, the four properties exposed by the Person class.


The Binding Builder is opened by clicking or right clicking on the Property Marker in the Properties Window. The Property Marker is the icon to the right of the property name. The Binding Builder is a GUI for editing bindings in WPF and Silverlight. This is a super feature.

The Cider Team has a great explanation of the new features on that you can read here: Setting Up Visual Studio for WPF and Silverlight Development. There is an article and video.

You can read additional Cider Team Online material here: WPF and Silverlight Designer for Visual Studio 2010. We are in the process of adding many more articles. While the material is initially geared for developers coming from other platforms to WPF or Silverlight, it has a lot of great information even for the seasoned XAML Head. Yea, I said it. I’m an XAML Head too and proud of it. (LOL)

Without d:DesignInstance, d:DesignData or d:Source applied to a CollectionViewSource, the Binding Builder would have no way to determine shape and provide a list of properties.

Note: If d:DataContext is not set, but DataContext is set and has a created type assigned to it, this will also supply shape that the Binding Builder can use for listing properties.

Creating Creatable Types

<Grid d:DataContext="{d:DesignInstance local:Person, IsDesignTimeCreatable=True}">

d:DesignInstance provides a technique for creating a non-faux type. Setting the property IsDesignTimeCreatable to True on the d:DesignInstance MarkupExtension enables this.


MSDN d:DesignInstance Walkthrough

Video showing d:DesignData and d:DesignInstance can be viewed from this blog post: Visual Studio 2010 Beta2 Sample Data Project Templates.

The above post also has source code for sample data templates. There are four of the templates which are tutorial walkthroughs on this topic and sample data.

The two .xaml files in the DesignInstance Samples folder are the walkthroughs. You can create this project in VB.NET or C# by using one of the below templates when creating your project.

  • VB WPF Application DesignData Sample – VB.NET Sample WPF Application that demonstrates consuming sample data.
  • CS WPF Application DesignData Sample – C# Sample WPF Application that demonstrates consuming sample data.
  • DesignInstanceExamples


Hope you find d:DesignInstance and d:DesignData Sample Data in Visual Studio 2010 Beta2 a productive feature for your application development.

Have a great day,

Just a grain of sand on the worlds beaches.

Posted in Cider Designer, CodeProject, Data Binding, Expression Blend, Silverlight, Tips, VB.NET, Visual Studio 2010, WPF General

Image 3 Image 4 Image 5 Image 6 Image 7 Image 8


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Karl Shifflett
United States United States

I’m a passionate Software Architect and Developer.

A long-time WPF-Prism fanatic who enjoys writing line of business applications, developer tools, and Visual Studio Extensions.

My front end passions are WPF, Xamarin.Forms, Electron, ES2015 (ES6), Node.js, WordPress, and Angular.

For the back end I use what is appropriate for the project: SQL Server and ASP.NET WebAPI, MongoDB, Express, Azure, AWS, Firebase, etc.

I am very pragmatic software engineer and strive to write simple, maintainable, and testable code. Simple code allows for solving complex problems in a maintainable way.

My Blog

My Github Repros

Just a grain of sand on the worlds beaches.

Comments and Discussions

General5'ed Pin
Amir Mahfoozi29-Nov-11 0:49
memberAmir Mahfoozi29-Nov-11 0:49 
GeneralMy vote of 4 Pin
Howard Richards26-Apr-11 14:52
memberHoward Richards26-Apr-11 14:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Technical Blog
Posted 28 Oct 2009

Tagged as


1 bookmarked