Content Index Search
 

Create, export, or import a resource dictionary

Resources in a resource dictionary can be applied anywhere within your application because resource dictionaries are linked to your project in the App.xaml file. You can package a set of resources into a resource dictionary file and re-use the entire file in another application. For instructions on how to move existing resources into a resource dictionary, see Move, copy, or export a resource.

To create a resource dictionary

  1. In the Resources panel, click the New Resource button.
    The Add New Item dialog 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 procedures in Move, copy, or export a resource 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 export a resource dictionary

You do not need to do anything to export a resource dictionary because a resource dictionary is a separate .xaml file that you can import into another project.

To import a resource dictionary

  1. In the Project panel or on the Project menu, do one of the following:
    • Click Add Existing Item to copy the resource dictionary into your project folder.
      The Add Existing Item window appears.
    • Click Link to Existing Item to link to a resource dictionary without copying it into your project folder.
      The Link to Existing Item window appears.
  2. Browse to your resource dictionary file, and then click Open.
    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.
    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, check your resource dictionaries for duplicate resource names, and rename resources as necessary. For instructions on renaming a resource, see Rename a resource.

To remove a resource dictionary

  1. In the Resources panel, expand the App.xaml node, right-click the link to the resource dictionary, and then click Delete.
    The Deleting Link dialog appears. Click Yes to continue removing the resource dictionary link, or click No to cancel.
  2. In the Project panel, right-click the resource dictionary that you want to remove, and then do one of the following:
    • Click Remove from project to remove the resource dictionary without deleting it from your project folder.
    • Click Delete to delete the resource dictionary file from your project folder.
    The Confirm File Remove dialog appears. Click Yes to continue removing the resource dictionary, or click No to cancel.
    The resource dictionary is removed from your project.
    Warning Check for any controls whose properties used the resources in the dictionary.