Move, copy, or export a resource
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 within a wider scope or more limited scope in your application. For example, if you define an object-level resource but want to make it available to you entire 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.
Some resources (such as styles or control templates) might make
use of 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 within the scope of the destination. If there are
already resources in the destination with duplicate names, a dialog 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. |
To export a resource
Resources can be exported by putting them in a resource dictionary file which can be added as an item to another project.
- 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 appears. - 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 following 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.
To move a resource
- 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.
- Using your mouse, click on 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.
To copy a resource
- 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.
- Right-click the resource name and then click Copy.
- Right-click the location where you want to copy the resource and then
click Paste.
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 copying. For instructions on renaming a resource, see Rename a resource.