Export (0) Print
Expand All

Move, copy, or export a resource

This page applies to WPF and Silverlight 2

Because resources can be defined in different scopes in your Microsoft Expression Blend application, it might become necessary to move an existing resource if you want to make the resource available in a wider or more limited scope in your application. For example, if you define an object-level resource but want to make it available to you whole application, you could move the resource to the App.xaml file. If you want to export a resource to another application, you could move the resource to an external resource dictionary.

Cc374992.alert_note(en-us,Expression.10).gifNote:

Resource dictionaries are not supported in Silverlight 2.

Cc374992.alert_caution(en-us,Expression.10).gifCaution:

Some resources (such as styles or control templates) might use additional resources (such as brush or color resources). When you move or copy resources, Expression Blend will move the additional resources if their key names cannot be resolved in the scope of the destination. If resources already in the destination have duplicate names, a dialog box is displayed to give you the option to overwrite the existing resources, create new resources with different names and update the references, or use the existing resources.

Note that if resources reference additional system resources, the system resources are not copied because they are always available.

Resources can be exported by putting them in a resource dictionary file that can be added as an item to another project.

To export a resource

  1. If you do not have a resource dictionary in which you want to export the resource, click the New Resource button in the Resources panel.

    The Add New Item dialog box appears.

  2. Enter a name for your resource dictionary and then click OK.

    The new resource dictionary is added as a new file in the Project panel, and listed as a container for resources in the Resources panel.

    You can now use the next procedure to move resources to the new resource dictionary. Additionally, when you create a new resource, you can select the new resource dictionary in the Define in section of the Create New Resource dialog box.

  1. In the Resources panel, locate the resource that you want to move by expanding the resource container nodes.

    • Application-level resources are listed under the App.xaml node.

    • Dictionary-level resources are listed under the node that is identified by the name of the resource dictionary file.

    • Document-level resources are listed under the node that is identified by the name of the root element in your document (for example, expand Window1.xaml, and then expand Window).

    • Object-level resources are listed under the node that is identified by the name of the object.

  2. Using your mouse, click the resource that you want to move, and then drag it to the new location. If you want to export the resource to another project, move the resource to a dictionary file.

  1. In the Resources panel, locate the resource that you want to move by expanding the resource container nodes.

    • Application-level resources are listed under the App.xaml node.

    • Dictionary-level resources are listed under the node that is identified by the name of the resource dictionary file.

    • Document-level resources are listed under the node that is identified by the name of the root element in your document (for example, expand Window1.xaml, and then expand Window).

    • Object-level resources are listed under the node that is identified by the name of the object.

  2. Right-click the resource name and then click Copy.

  3. Right-click the location where you want to copy the resource and then click Paste.

    Cc374992.alert_caution(en-us,Expression.10).gifCaution:

    If two different resources in the same project have the same name, you might get unexpected results on the artboard if the wrong resource is applied to a control. To avoid this problem, rename the original or the copied resource after you copy. For instructions on renaming a resource, see Rename a resource.

Community Additions

ADD
Show:
© 2014 Microsoft