Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

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.

To add a CLR object data source

  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 Create data source Ee341451.601d2ab6-5e4b-49ab-bb3c-064456dc8184(en-us,Expression.40).png, and then click Create Object Data Source.

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

    tip noteTip

    If you also want to see the available system assemblies, you can select the Show All 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.40).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.

See also

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.