Export (0) Print
Expand All

Apply a style resource

This page applies to WPF and Silverlight 2

You can use the style of a control in Microsoft Expression Blend 2 project to specify triggers (WPF) or states (Silverlight 2) 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 control's appearance, and the triggers or states 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.

Cc295342.alert_note(en-us,Expression.10).gifNote:

You cannot create a style or a control template for one control that will effect a change on another control. However, you can use event triggers directly on one control to effect a change on another control. For more information, see Add or remove a trigger in this User Guide.

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.

Cc295342.alert_tip(en-us,Expression.10).gifTip:

To apply a style, you must first create a style. For more information about how to create a style, see Create a style resource in this User Guide.

  • On the artboard or under Objects and Timeline in the Interaction 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 the Advanced property options Cc295342.d6ba8f4a-b8a2-445a-af0b-a267dfade6e1(en-us,Expression.10).png button next the Style property, point to Local Resource, and then click the named style that you want to apply.

    Cc295342.alert_note(en-us,Expression.10).gifNote:

    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.

  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.

    Cc295342.alert_note(en-us,Expression.10).gifNote:

    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 Controls tab of the Asset Library, selecting the style, and then drawing on the artboard.

Community Additions

ADD
Show:
© 2014 Microsoft