Generate sample data from class

Use Create Sample Data from Class if your project is using Views and ViewModels and you want to view sample data in your ViewModel at design time. After you have created a ViewModel on the artboard, drag the sample data from the Data panel onto the root of the view to set a design-time data context (the d:DataContext property). You can then design the View using the sample data that has been generated.

To generate sample data from class

  1. To enable the sample data tools, open a XAML document on the artboard in Design view Ff724024.32be2832-9f81-4617-97e6-a4a3988a136c(en-us,Expression.40).png or Split view Ff724024.5b79e600-984e-4f44-b8cd-6c1522832ad4(en-us,Expression.40).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 Create sample data Ff724024.30540d76-7256-43ce-b5d9-4b2edf3d339f(en-us,Expression.40).png, and then click Create Sample Data from Class.

  4. In the Create Sample Data from Class dialog box, in the Data source name box, type a name for your data source.

  5. In the Select class list, select the data source assembly that you want. The Select class list displays the default project assemblies in addition to any data source assemblies that you have explicitly added as references in your project.


    To see all the available assemblies, select Show all assemblies.


    Type a term into the Search box to filter the list to include only those assemblies that contain the search term.

  6. Click OK.

Send feedback about this topic to Microsoft. © 2011 Microsoft Corporation. All rights reserved.