BT

New Early adopter or innovator? InfoQ has been working on some new features for you. Learn more

Karl Shifflett Shows How to make VS 2010’s Binding Builder Actually Work

| by Jonathan Allen Follow 6 Followers on Jun 16, 2010. Estimated reading time: 1 minute |

Visual Studio 2010 comes with a feature they call the “Binding Builder”. This tool, launched from the properties pane, helps developers quickly construct XAML bindings for WPF and Silverlight. But without some help, it doesn’t work when the data context is only set at runtime.

Karl explains the problem comes down to a lack of information. The IDE has no way of knowing what type of object is going to be bound to the data-context, which in turn means it can’t examine the bindings for errors. The work-around is quite simple; just give it a data-context that is only used at design time.

To do this you need to add a “d:DataContext” property to the same object that will get the real data context. When the IDE sees both a normal and a design-time data-context it will use the design-time one. To further facilitate this design is the addition of the “d:DesignInstance” markup extension. This will create a fake type with the same properties as the indicated type, allowing classes to be used even if they don’t have a default constructor.

For more information on the Binding Builder and design-time markup extensions, see Karl’s post on the WPF and Silverlight Designer blog.

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT