Replace with XAML Resource (XAML)

Replaces the current string value with the reference to an appropriate string in the resource file.

Availability

Available from the context menu or via shortcuts:

  • when the cursor is on a string value, provided that the resource file contains the same string value.

Examples

<%-- Words.xaml --%>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                    xmlns:System="clr-namespace:System;assembly=mscorlib">
    <System:String x:Uid="Word_Testtext" x:Key="Word_Testtext">Test text</System:String>
    <System:String x:Uid="Button_Name" x:Key="Button_Name">My Button</System:String>
<Brush x:Uid="Word_Aqua" x:Key="Word_Aqua">Aqua</Brush>
</ResourceDictionary>

Result:

<%-- Window.xaml --%>
<Window x:Class="MyWpfApplication.Window"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Words.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Window.Resources>
    <Grid>     
        <Button Background="{StaticResource Word_Aqua}" Height="49"  Width="124">MyButton</Button>
</Grid>
</Window>

Screenshot

rsReplaceWithXAMLResource