Apply a style resource (Blend for Visual Studio)

You can use the style of a control in Blend for Visual Studio 2012 project to specify states and properties 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 appearance of the control, and the states will affect how the control responds to property changes and events. For example, you can create a style for a button that causes the background color of the button to change when the pointer moves over the button.

Style resources save you time by allowing you to define the appearance and behavior for a type of control and then apply that style to multiple instances of that type of control on the artboard.

Tip

To apply a style, you must first create a style.

For information about how to create a style, see Create a style (Blend for Visual Studio).

To apply an existing style resource to a control on the artboard

  • On the artboard or in the Objects and Timeline panel, click an object to select it, and then do one of the following:

    • On the Object menu, point to Edit Style, point to Apply Resource, and then click the named style that you want to apply.

    • Under Miscellaneous in the Properties panel, click Advanced options JJ155163.12e06962-5d8a-480d-a837-e06b84c545bb(en-us,VS.110).png next the Style property, point to Local Resource, and then click the named style that you want to apply.

    Note

    If you do not see your style resource listed, the resource might have been created for a different type of control. For example, a resource that was created from a button object cannot be applied to a check box control.

To use a style resource to create a control on the artboard

  1. In the Resources panel, locate the style resource for the control that you want to add to the artboard. You might have to expand the nodes in the Resources panel to see the resource.

  2. Drag the style resource to the artboard.

    A control is added to the artboard with the style already applied.

    Note

    If the style is defined in a resource dictionary, you can also add it to the artboard by selecting the name of the resource dictionary in the Styles category of the Assets panel, selecting the style, and then drawing on the artboard.