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
To enable the sample data tools, open a XAML document on the artboard in Design view or Split view .
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.
In the Data panel, click Create sample data , and then click New Sample Data.
In the New Sample Data dialog box, type a descriptive name for your data source in the Data source name field.
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.
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.
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.
[!NOTA]
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, such as a DataGrid object, to display the data.
You can also modify the sample data, adding properties and changing values.
For more information, see Modify sample data.
Vedere anche
Attività
Import sample data from an XML file