Share via


Generate sample data

You can use the tools in the Data panel of Microsoft Expression Blend to generate sample data for your application. Sample data is useful when you are designing the appearance of controls that will display live data that you might not have access to at design time.

To generate sample data

  1. To enable the sample data tools, open a XAML document on the artboard in Design view Ee341450.32be2832-9f81-4617-97e6-a4a3988a136c(en-us,Expression.30).png or Split view Ee341450.5b79e600-984e-4f44-b8cd-6c1522832ad4(en-us,Expression.30).png.

  2. If you do not see the Data panel, make sure that a check mark appears next to Data on the Window menu.

    For more information, see Add or remove a workspace panel.

  3. In the Data panel, click Add sample data source Ee341450.30540d76-7256-43ce-b5d9-4b2edf3d339f(en-us,Expression.30).png, and then click Define New Sample Data.

  4. In the Define New Sample Data dialog box, type a descriptive name for your data source in the Data source name field.

  5. Under Create data source in, select one of the following:

    • Project   Use this option to make the data available to all documents in the project.

    • This document   Use this option to make the data available only to the currently-open XAML document.

  6. If you want your application to be able to display sample data when you run it (F5), make sure Enable sample data when application is running is selected. If this option is not selected, you will be able to see sample data only on the artboard, and not in your application window at run-time.

  7. Click OK to close the Define New Sample Data dialog box and create the sample data.

    In the Projects panel, in a folder named SampleData, a subfolder is added for your new sample data source. It contains the files required to define the data.

    In the Data panel, you can expand the nodes of your new data source to view the schema of your sample data. An initial collection of strings and boolean properties was generated by Expression Blend.

    Ee341450.496d7ebc-fe46-42f6-95a8-57b0e5be5d49(en-us,Expression.30).png

    Note

    The Data panel shows you the structure (or schema) of your data, not the data itself. For example, in the Data panel, you will see a Collection node, under which you will see a string property (Property1), meaning that your data consists of a collection of records where each record contains a string. To view the actual data that was generated, click Edit sample values Ee341450.05e097fd-b5b7-4a06-b97a-bf7ece17b6c6(en-us,Expression.30).png next to the Collection node Ee341450.94dad06c-7ddb-4c5e-b2ee-74b394c713ff(en-us,Expression.30).png.

    You can now drag the Collection node onto the artboard to create a list box, or onto an existing object, such as a DataGrid object, to display the data.

    List of items created by dragging the initial generated collection onto the artboard
    Ee341450.23ff15ed-b181-417f-b57f-9605d96312ea(en-us,Expression.30).png
    List of items after dragging the initial generated collection onto a DataGrid object
    Ee341450.917dd79d-8fe8-4e82-970b-55c9705a5e3e(en-us,Expression.30).png

    You can also modify the sample data, adding properties and changing values.

    For more information, see Modify sample data.

See also

Tasks

Modify sample data

Import sample data from an XML file

Other resources

Displaying data in controls