Create a style resource
You can use the style of a control in Microsoft® Expression Blend to specify properties and triggers that will be used as defaults by the control to which the style is applied. The properties (such as the background brush color) will affect the control's appearance, and the triggers will affect how the control responds to property changes and events. For example, when the user moves their mouse over the control, the IsMouseOver property changes from False to True and the MouseOver event fires. You can create a style for a button that causes the background color of the button to change when the mouse pointer moves over the button. If you want to modify the structure of a control, create a template instead using the procedures in Edit a control template.
Because a style is a resource, you can save the style separately from the button, and then apply the style resource to other button objects. For more information about resources, see Resources overview in this User Guide.
To create a new style resource for a control
- On the artboard or under Objects and Timeline in the Interaction panel, select the object for which you want to create a style.
- On the Object menu, point to Edit Style,
and then do one of the following:
- To create a new empty style, click Create Empty. For shape controls (such as Rectangle) and text controls (such as TextBox), this is the only option that is available.
- To create a new style that is based on the style that is currently in use by the selected object (whether the style is the default style for the object or is a custom style that you created previously), click Edit a Copy.
- Under Resource name (Key), do one of the following:
- To create a new named style for the element, enter a key name. This is the name by which other elements can reference the style, thus applying the style.
- To create a style that will be used by all elements of this type, select Apply to all.
|In the XAML for the style element that will be created, an attribute named
- To make the style available to any document in your application, select Application.
- To make the style available only to the current document, select This document (Window: Window)
- To define the style in a resource dictionary file that can be reused in other projects, select Resource dictionary. You can then select an existing resource dictionary file or create a New one.
|You are effectively creating a new style resource here. This will become a local resource and can be viewed and modified easily using the Resources panel.|
This returns you to the previous editing scope you were working from.
|Notice that once you create or apply a style resource to an object, a green highlight appears in the Properties panel for the Style property of the selected object to indicate that the object is now bound, or linked, to this style resource.|