Rename a resource

When a resource is applied to a property, the resource is not referred to by its name (or x:Name attribute in XAML)—the resource is referred to by their resource dictionary key (or x:Key attribute in XAML). To rename a resource, you need to change the key using one of the following methods.

To rename a resource in Design view

  1. In Design view, in the Resources panel, click the resource that you want to change until the name becomes editable.

  2. Type in a new name and press ENTER.

    If there are any objects that still reference the old name of the resource, a popup window appears, listing the objects. In this window, you can choose from the following actions:

    • Update the affected properties to reflect the new resource name.

    • Convert the property to a local string value.

    • Reset the properties to default values.

    • Choose not to fix the broken resource references.


    In the Existing References Found window, if you choose not to fix anything, there will be build errors unless you create a new resource with the old name before you build your application

To rename a resource in XAML view

  1. In XAML view, locate the section that defines your resource. You can use one of the following methods:

    • In XAML view, use the Find feature (CTRL+F) to enter the name of your resource.

    • In Design view, in the Resources panel, right-click the resource that you want to change and click View XAML. This will switch to XAML view with the XAML code for the resource highlighted.

  2. The name of the resource is defined in the x:Key attribute of the opening tag. If there are no objects in your project whose properties reference the resource, you can change the x:Key attribute value to the new name. Otherwise, you can use the Find and replace feature (CTRL+H) to rename all instances of the name and avoid build errors.