Share via


Generate sample data

You can use the tools in the Data panel of Blend for Visual Studio 2012 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.

In addition to being able to generate sample data based on a schema you define manually, you can also generate sample data based on a class. When you create sample data from a class, the data is available in the form of a XAML file, and stored in the SampleData folder.

To generate sample data

  1. To enable the sample data tools, open a XAML document on the artboard in Design view  or Split view .

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

  3. In the Data panel, click Create sample data , and then click New Sample Data.

  4. In the 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 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 Blend.

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 next to the Collection node .

You can now drag the **Collection** node onto the artboard to create a list box, or onto an existing object.
List of items created by dragging the initial generated collection onto the artboard

List of items after dragging the initial generated collection onto a DataGrid object

You can also modify the sample data, adding properties and changing values. For more information, see [Modify sample data (Windows Phone)](jj735500\(v=vs.105\).md).

See Also

Tasks

Modify sample data (Windows Phone)

Import sample data from an XML file (Windows Phone)