BT

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

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

Bookmarks

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
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.

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

Community comments

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

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

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.