Create a brush resource or color resource
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.
[!REMARQUE]
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. For more information about how to create additional resource types, see Creating reusable resources. You can see all the resources that are used in your project in the Resources panel.
To create a brush resource
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 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.
Under Brush in the Properties panel, click the Solid color brush tab , the Gradient brush tab , or the Tile brush tab to begin setting properties for your brush.
When you are ready to save the brush, click Advanced options 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
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.
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
To apply a brush resource to another object
Select the object to which you want to apply the brush resource.
Under Brush in the Properties panel, select the brush property that you want to change.
Click the Brush resources tab .
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 Brush1 resource
[!REMARQUE]
You have other ways to apply a resource to an object, such as dragging the resource onto the artboard or using the Advanced options drop-down menu . For more information, see Apply or remove a resource.
To create a color resource
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 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.
Under Brush in the Properties panel, click the Solid color brush tab or the Gradient brush tab . Select a color in the color editor. If you are modifying a Gradient brush , you can select a color for each gradient stop .
Conseil A Color eyedropper appears in the lower-right corner of the color Editor when you are modifying a Solid color brush or a gradient stop on a Gradient brush . 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 , you can select the Gradient eyedropper and drag a line across a sample of a color anywhere inside the Blend for Visual Studio 2012 application window to apply it to the brush. You can press the ESC key at any time to cancel out of the eyedroppers.
When you are ready to save the color, click Convert color to resource .
Converting a color to a resource
The Create Color Resource dialog box appears
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.
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
Select the object to which you want to apply the color resource.
Under Brush in the Properties panel, select the brush property that you want to change.
Click the Color resources.
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
Voir aussi
Tâches
Convert an image to a reusable ImageBrush resource