Apply or remove a resource

This page applies to WPF and Silverlight 2

To apply a resource to an object or property

  1. Under Objects and Timeline, select the object that you want to apply a resource to.

  2. Do one of the following:

    • To apply a resource to a property

      In the Properties panel, click the Advanced property options Cc374991.d6ba8f4a-b8a2-445a-af0b-a267dfade6e1(en-us,Expression.10).png marker beside the property, point to Local Resource or System Resource, and then click an available resource from the list that appears.

      If you do not see a resource that you expect, it might be because the types of the resources do not match. If you do not want to choose one of the available resources, then you can come back to this step after you create a new resource (see Create a resource), or create a value converter to convert the resource you want to the data type that you need (see Try it: Create and apply a value converter).

    • To apply a style or template resource to a control

      Select a control object under Objects and Timeline, and then in the Object menu, point to Edit Style or Edit Control Parts (Template), point to Apply Resource, and then click the name of the template from the list that appears.

      If you know that a control template exists for your control but the Apply Resource item is not enabled under Edit Control Parts (Template), then try the Apply Resource item under Edit Style. Control templates that you create in Microsoft Expression Blend are wrapped in style resources in order to make them easier to manage.

    • To apply any resource to any object

      Drag and drop a resource from the Resources panel onto an object on the artboard. A pop-up window appears that displays a list of properties to which you can apply the resource.

    Note

    Resources can be applied wherever they’re compatible. For example, a brush resource can be applied to the Foreground property of a TextBox.

To remove a resource from an object or property

  1. Under Objects and Timeline, select the object that you want to remove a resource from.

  2. Do one of the following:

    • To reset a property to its default value

    Click the Advanced property options Cc374991.d6ba8f4a-b8a2-445a-af0b-a267dfade6e1(en-us,Expression.10).png marker next to the property in the Properties panel, and then click Reset from the list that appears.

    • To copy the value of the resource to a property and break the reference link

    Click the Advanced property options Cc374991.d6ba8f4a-b8a2-445a-af0b-a267dfade6e1(en-us,Expression.10).png marker next to the property in the Properties panel, and then click Convert to Local Value from the list that appears.

    • To assign another resource or value to a property or object

    Follow the steps that you would normally do to set the property or template.

    The link to the previous resource will be replaced with the new setting.

    Note

    Removing a resource from an object or property does not delete the resource from your project. For more information, see Delete a resource.