Share via


Create a brush or color resource (Blend for Visual Studio)

You can create a reusable brush or color that you can then apply to other objects. Resources have an advantage over copying and applying attributes because you can change the resource in one location. When you do this, all the objects that use the resource are instantly updated.

Note

You have many ways to create a resource in Blend for Visual Studio 2012. This topic covers only how to create brush and color resources, but you can create a resource from most properties. Additionally, you can create a style or template resource that you can apply to a control, instantly changing the appearance or behavior of the control. You can see all the resources that are used in your project in the Resources panel.

To create a brush resource

  1. If you do not already have an object on the artboard with a brush property that you want to convert to a resource, you can select Ellipse JJ155197.8938cfdf-9b75-4a33-bc88-b0636e114a0d(en-us,VS.110).png from the Tools panel, and draw an ellipse on the artboard. The properties panel will display the properties for the new ellipse object, with the Fill property selected under Brush.

  2. Under Brush in the Properties panel, click the Solid color brush tab JJ155197.3a66ec96-47bb-47fc-8876-6b9456feec3a(en-us,VS.110).png, the Gradient brush tab JJ155197.91fb0c61-7b3b-4ae7-8a59-760e625e3bd7(en-us,VS.110).png, or the Tile brush tab JJ155197.14623a18-70ab-450f-af01-ae9902d60e4d(en-us,VS.110).png to begin setting properties for your brush.

  3. When you are ready to save the brush, click Advanced options JJ155197.12e06962-5d8a-480d-a837-e06b84c545bb(en-us,VS.110).png next to the brush property (such as the Fill or Background property), and then click Convert to New Resource.

    The Create Brush Resource dialog box appears

    JJ155197.092a1fec-f5b5-427c-a51e-aae1f6a1eee2(en-us,VS.110).png

  4. In the Create Brush Resource dialog box, enter a name (key) for your new resource, select where you want the resource to be defined (such as at the application-level, document-level, object-level, or as a part of a resource dictionary), and then click OK.

  5. You can view and modify the brush resource that you created in the Resources panel.

    Viewing and modifying a brush resource in the Resources panel

    JJ155197.64136c65-52bc-4225-a948-b1171634baca(en-us,VS.110).png

To apply a brush resource to another object

  1. Select the object to which you want to apply the brush resource.

  2. Under Brush in the Properties panel, select the brush property that you want to change.

  3. Click the Brush resources tab JJ155197.415db740-5a54-48d2-8678-245ccfa7ee8b(en-us,VS.110).png.

  4. Under Local Brush Resources, select the brush resource that you want to apply to the object.

    Setting the Fill property of the selected object to the TransparentBrush resource

    JJ155197.af28e5e4-4861-45ac-b02d-e65386520ed7(en-us,VS.110).png

    Note

    You have other ways to apply a resource to an object, such as dragging the resource onto the artboard or using the Advanced options menu JJ155197.12e06962-5d8a-480d-a837-e06b84c545bb(en-us,VS.110).png. For more information, see Apply or remove a resource (Blend for Visual Studio).

To create a color resource

  1. If you do not already have an object on the artboard with a color property that you want to convert to a resource, you can select Ellipse JJ155197.8938cfdf-9b75-4a33-bc88-b0636e114a0d(en-us,VS.110).png from the Tools panel, and draw an ellipse on the artboard. The Properties panel will display the properties for the new ellipse object, with the Fill property selected under Brush.

  2. Under Brush in the Properties panel, click the Solid color brush tab JJ155197.3a66ec96-47bb-47fc-8876-6b9456feec3a(en-us,VS.110).png or the Gradient brush tab JJ155197.91fb0c61-7b3b-4ae7-8a59-760e625e3bd7(en-us,VS.110).png. Select a color in the color editor. If you are modifying a Gradient brush JJ155197.91fb0c61-7b3b-4ae7-8a59-760e625e3bd7(en-us,VS.110).png, you can select a color for each gradient stop JJ155197.a3c9e482-e99b-4504-8a02-9507487d1791(en-us,VS.110).png.

    Tip

    A Color eyedropper JJ155197.2ab2d2fb-3478-4b33-87fb-3cdeb9df4d52(en-us,VS.110).png appears in the lower-right corner of the color Editor when you are modifying a Solid color brush JJ155197.3a66ec96-47bb-47fc-8876-6b9456feec3a(en-us,VS.110).png or a gradient stop on a Gradient brush JJ155197.91fb0c61-7b3b-4ae7-8a59-760e625e3bd7(en-us,VS.110).png. With this eyedropper selected, you can grab a color sample from anywhere on your desktop and apply it to the selected brush. When you modify a Gradient brush JJ155197.91fb0c61-7b3b-4ae7-8a59-760e625e3bd7(en-us,VS.110).png, you can select the Gradient eyedropper Gradient eyedropper icon and drag a line across a sample of a color anywhere inside the Blend application window to apply it to the brush. You can press the ESC key at any time to cancel out of the eyedroppers.

  3. When you are ready to save the color, click Convert color to resource JJ155197.6bf68607-add8-4d87-b6f4-100c8f05dd17(en-us,VS.110).png.

    Converting a color to a resource

    JJ155197.89203705-cf66-46e0-b153-52a23cd744f7(en-us,VS.110).png

    The Create Color Resource dialog box appears

    JJ155197.6bff8b19-3cd5-41a0-bbf9-ff65532d5aae(en-us,VS.110).png

  4. In the Create Color Resource dialog box, enter a name (key) for your new resource, select where you want the resource to be defined (such as at the application-level, document-level, object-level, or as a part of a resource dictionary), and then click OK.

  5. You can view and modify the color resource that you created in the Resources panel, just as you can view and modify a brush resource.

To apply a color resource to another object

  1. Select the object to which you want to apply the color resource.

  2. Under Brush in the Properties panel, select the brush property that you want to change.

  3. Click the Color resources.

  4. Under Local Color Resources, select the color resource that you want to apply to the object.

    Setting the Fill property of the selected object to the Color1 resource

    JJ155197.5cb88f90-c17a-4dad-be87-b6be7d74f410(en-us,VS.110).png

See Also

Tasks

Convert an image to a reusable brush resource

Copy or apply attributes to an object (Blend for Visual Studio)