Add or modify a data store
You can use the data store to store data properties and values in order to make them easier to use throughout your project. You can also add new properties or modify existing properties in a data store by using built-in behaviors.
The most common way to create a data store is by using the SetDataStoreValueAction behavior. The SetDataStoreValueAction behavior creates a data store when you define a new property in the Common Properties category of the Properties panel. You can also explicitly create a data store by using the Data panel.
After the data store has been created, either by using SetDataStoreValueAction or by creating a data store in the Data panel, you can then modify your data by using SetDataStoreValueAction. You can also be notified when a property in your data store has changed by using DataStoreChangedTrigger.
To create a data store
In the Data panel, click **Create data source **, and then click New Data Store. The New Data Store dialog box appears.
In the New Data Store dialog box, in the Data source name box, type a name for your data store.
Under Define in, select Project to make the data store available to any document in your application, or select This document to make the data store available only in the current document. Click OK.
The data store appears in the Data panel.
To display values from the data store
In the Data panel, drag the property that you want onto the artboard.
If you drag the property onto the LayoutRoot, Blend creates a TextBlock, and then binds the property you dragged to the TextBlock that was just created.
If you drag the property onto an existing object, the Create Data Binding dialog box appears. In the Property of drop-down list, choose the property of the object that you want to bind to the property that you just dragged.
Add or remove properties, values or data to or from the data store
You can add properties and values by using the SetDataStoreValueAction behavior. You can also add properties and values in the Data panel.
To add properties and values to the data store
In the Data panel, click the plus sign next to the data store that you want to add a property to.
In the Property name box, type a name for your new property.
To assign a value to the property that you just created, click Edit data store values . In the Configure Data Store dialog box, in the Value column, double-click the cell that contains the value that you want to change. By default, a sample value appears in the cell.
Conseil You can modify any of the information that appears in the Configure Data Store dialog box: Property name, Value, and Type. Double-click the cell that contains the information that you want to change, and then change the information according to your preferences.
To remove a property from the data store
- In the Data panel, right-click the property that you want to remove, and then click Remove.
To remove the data store
- In the Data panel, right-click the data store that you want to remove, and then click Remove.