Use an object data source to connect to a database

You can add data sources directly to your Microsoft Expression Blend project.

In a team production environment, developers might provide common language runtime (CLR) data sources to designers so that the designers can bind to data in their Expression Blend projects in any way that they choose. A CLR data source is implemented in a class library assembly (.dll). The implementation populates a data table or data set from a database (such as a SQL database), and converts the data to an ObservableCollection so that Expression Blend (or any application that uses Windows Presentation Foundation (WPF)) can bind to the data.

For an example of a class library that is written in C# and an Expression Blend project that binds to the resulting data, see Try it: Display data from a sample SQL database.

  1. On the Project menu, click Add Reference (ALT+SHIFT+R).

    The Add Reference dialog box appears.

  2. Browse to the assembly (.dll) that implements a data source. Select the assembly, and then click Open.

    The .dll file is added to the Reference node in the Projects panel.

  3. In the Data panel, click Add Live Data Source Ee341451.601d2ab6-5e4b-49ab-bb3c-064456dc8184(en-us,Expression.30).png, and then click Define New Object Data Source.

    The Define New Object Data Source dialog box appears. Under Select the class to create an instance of, the following assemblies will be listed:

    • Any data source assemblies that you have added as references in your project.

    • Default project assemblies.


    If you also want to see the available system assemblies, you can select the Show System Assemblies check box. Typing a query in the Search box will filter the assemblies to those that contain the search query. Remember to clear the Search box if you want to see all the assemblies again.

  4. In the Data source name field, either type a name for this data source or leave the name as the default (ObjectDataSource).

  5. Under Select the class to create an instance of, expand the name of your assembly, select the object, and then click OK.

    The Data panel is now populated with the live data Ee341451.dc8f65fe-8ab3-4a8e-8963-e97ab3e4423c(en-us,Expression.30).png that is parsed from the data source. The data type for each node in the data source is listed in parentheses. You can now bind objects in your project to the data. For more information, see Bind an object to data.

Community Additions