Rename a resource (Blend for Visual Studio)

When a resource is applied to a property, the resource is referred to by its 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.

    Warning

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

To rename a resource in Code view

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

    • In Code 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 Source. This will switch to Code 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 (Windows Store apps) feature (Ctrl+H) to rename all instances of the name and avoid build errors.

    Find and replace