Partager via


Apply or remove a resource

To apply a resource to an object or property

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

  2. Do one of the following:

    • Apply a resource to a property   In the Properties panel, click Advanced options JJ170849.12e06962-5d8a-480d-a837-e06b84c545bb(fr-fr,VS.110).png next to 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, you can come back to this step after you either create a new resource or create a value converter to convert the resource you want to the data type that you need.

      For more information, see Create a resource and Create, export, or import a resource dictionary.

    • Apply a style or template resource to a control   Select a control object under Objects and Timeline. On the Object menu, point to Edit Style or Edit 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 Template, try the Apply Resource item under Edit Style. Control templates that you create in Blend for Visual Studio 2012 are wrapped in style resources in order to make them easier to manage.

    • Apply any resource to any object   Drag 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.

    [!REMARQUE]

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

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:

    • Reset a property to its default value   Click Advanced options JJ170849.12e06962-5d8a-480d-a837-e06b84c545bb(fr-fr,VS.110).png next to the property in the Properties panel, and then click Reset from the list that appears.

    • Copy the value of the resource to a property and break the reference link   Click Advanced options JJ170849.12e06962-5d8a-480d-a837-e06b84c545bb(fr-fr,VS.110).png next to the property in the Properties panel, and then click Convert to Local Value from the list that appears.

    • Assign another resource or value to a property or object   Follow the steps that you would typically follow to set the property or template.

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

    [!REMARQUE]

    Removing a resource from an object or property does not delete the resource from your project.

    For more information, see Delete a resource.

To view the resources that are applied to an object

  1. Select an object on the artboard or in the Objects and Timeline panel.

  2. In the Resources panel, click Show resources used by selected element JJ170849.78ae7c9e-3f75-484c-a92f-452415ea197f(fr-fr,VS.110).png.

    The object name appears in the Resources panel. Expand the node to view the list of resources that are applied to the object. You can select other objects to view the resources that are applied to those objects.

    ConseilConseil

    Remember to click Show all resources JJ170849.45b4560e-cca4-48e9-b32a-f15a8a342bc7(fr-fr,VS.110).png when you want to return to the list of all resources.