Export (0) Print
Expand All

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

  1. In the Resources panel, click Create new resource dictionary Cc374990.35c35d1d-ac87-42f7-adc4-d620dbe60297(en-us,Expression.30).png.

  2. The New Item dialog box appears.

  3. Type a name for your resource dictionary, and then click OK.

  4. 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 box.

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

  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 is listed as a container for resources in the Resources panel.

    Cc374990.alert_caution(en-us,Expression.30).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, check your resource dictionaries for duplicate resource names, and rename resources as necessary.

    For instructions on renaming a resource, see Rename a resource.

  1. Check for any controls whose properties use the resources in the dictionary that you want to remove. If there are resources that you want to save, drag them to a different location in the Resources panel, such as a different resource dictionary, or the App.xaml file.

  2. 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 box appears. Click Yes to continue removing the resource dictionary link, or click No to cancel.

  3. 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 box appears. Click Yes to removing the resource dictionary.

    The resource dictionary is removed from your project.

Community Additions

ADD
Show:
© 2014 Microsoft