Create a resource

This page applies to WPF and Silverlight 2

Whenever you create a new resource from an existing property, style, or template, the Create Resource dialog box allows you to define the resource at the application-level, document-level, or object-level, which determines where you can use the resource. For example, if you define the resource at the object level, then the resource can only be applied to the object on which you created it. You can also select to store the resource in a resource dictionary - a separate file that you can use again in another project.

  1. Create an object or select an object under Objects and Timeline in the Interaction panel.

  2. In the Properties panel, click the Advanced property options Cc295326.d6ba8f4a-b8a2-445a-af0b-a267dfade6e1(en-us,Expression.10).png button beside a property, and then click Convert to New Resource. If the property is in the Brushes category of the Properties panel, you can also create the resources using the Convert brush to resource button Cc295326.c8731c39-2e16-47f5-acf0-1c92a8a5381e(en-us,Expression.10).png.The appropriate dialog box for creating resource appears.

    The Create Brush Resource dialog that appears when creating a resource from a brush

  3. Under Resource name (Key), enter a key name. This is the name by which other elements can reference the resource, thus applying the resource to themselves.

  4. Under Define in, select the option where you want the 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 can be reused in other projects, select Resource dictionary. You can then select an existing resource dictionary file or create a New one.


      Resource dictionaries are not supported in Silverlight 2.

  5. Click OK to exit the dialog box, create the resource, and apply it to the object from which you created it. You can view the new resource in the Resources tab, from where you can drag it onto another object on the artboard and select the property to apply it to. For more methods of applying a resource, see Apply or remove a resource.

Community Additions