Move or copy a resource

Because resources can be defined in different scopes in your Blend for Visual Studio 2012 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.

Warning

Some resources (such as styles or control templates) might use additional resources (such as brush or color resources). When you move or copy resources, 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.

To move a resource

  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 MainPage.xaml, and then expand Page).

    • 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.

To copy a resource

  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 MainPage.xaml, and then expand Page).

    • 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.

    Warning

    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 (Blend for Visual Studio).