In this article

Walkthrough: Using a DesignInstance to Bind to Data in the Designer

02/04/2013

3 minutes to read

In this article

This walkthrough shows you how to use the WPF Designer for Visual Studio to create data bindings at design time for a data context that is assigned at run time. To create the data binding, you use the data binding builder to create a special design-time data context and set the DesignInstance to a business object type. DesignInstance is a design-time property.

In this walkthrough, you perform the following tasks:

Create the project.

Create a Customer class business object.

Data bind a TextBox control to a design-time instance of the Customer class in a data context.

When you are finished, you will have a text box that is bound at run time to a business object. The data binding is set in the WPF Designer.

Note

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Working with Settings.

Prerequisites

You need the following components to complete this walkthrough:

Visual Studio 2010.

Creating the Project

The first step is to create a WPF Application project and enable the design-time properties.

This XAML establishes a design-time data context and makes the Customer class available for creating data bindings.

Build the solution.

Creating the Data Binding

Now you can create data bindings to the Customer business object by using the data binding builder. The following procedure shows how to bind a TextBox control to the FirstName property of a Customer object.