Convert an image to a reusable ImageBrush resource
An ImageBrush is a type of TileBrush that uses an image as its source. You can create an image brush resource from an image file, and then apply that brush resource to another object.
[!NOTA]
If you want to include other types of objects in your brush resource, see one the following topics:
Convert a video into a reusable VideoBrush resource in Blend (Silverlight only)
Convert objects into a reusable DrawingBrush resource (WPF only)
Convert objects into a reusable VisualBrush resource(WPF only)
To convert an existing image on the artboard into a brush resource
Add an image file to your project by clicking AddExistingItem on the File menu, browsing to your image file, and then clicking Open.
In the Projects panel, double-click the image file to add it to the artboard.
The image file is added as an Image object that you can resize and modify on the artboard.
In the Objects and Timeline panel, select the Image object that you created in the previous step.
On the Tools menu, point to Make Brush Resource, and then click Make ImageBrush Resource. An image brush can paint an area with an image. It is a type of tile brush that defines its content as an image.
The Create ImageBrush Resource dialog box opens.
Under Name (Key), enter a name for your image brush resource. This is the name by which other objects can reference the resource, thereby applying the resource to themselves.
Under Define in, select the option where you want the image brush resource to be defined:
To make the resource available to any document in your application, select Application.
To make the resource available only to the current document, select This document (Window: Window).
To make the resource available only to the object from which you created the resource or its child objects, select This document (object).
To define the resource in a resource dictionary file that you can reuse in other projects, select an existing Resource dictionary, or click the New button to create a new resource dictionary.
Click OK to close the dialog box and create the resource. The original image remains in your document.
You can view the new image brush resource in the Resources tab, from which you can drag it onto another object on the artboard and select the brush property to apply it to.
For more methods of applying a resource, see Apply a solid color or gradient brush to an object's fill or stroke.
To create a new brush resource in the Resources panel
If you want to create a brush resource in a new resource dictionary, click Create new resource dictionary , type a name for the resource dictionary, and then click OK.
Otherwise, you can select an existing location later in this procedure when you create your brush resource.
Copy image data to the Clipboard. For example, you could right-click an image file in File Explorer and click Copy, or capture a screen image, or use the Copy feature in a design program to copy a portion of an image.
In the Resources panel of Blend for Visual Studio 2012, right-click the location where you want to save the image brush resource, and then click Paste. For example, you could right-click one of the following locations:
The App.xaml file Right-click this location to make your image brush resource available to all the documents and objects in your application.
A resource dictionary file Right-click this location to save your image brush in a resource dictionary. A resource dictionary can be linked to the App.xaml file, to another resource dictionary, or to the root object of the document that is open on the artboard.
An object in the open document Right-click this location to make the image brush resource available only to the selected object.
A new image brush resource is created. You can now drag the resource onto objects on the artboard to apply the resource to one of the brush properties of the object.
Vedere anche
Attività
Create a brush resource or color resource
Apply a solid color or gradient brush to an object's fill or stroke