This documentation is archived and is not being maintained.

BamlLocalizableResourceKey Class

Represents a key that is used to identify localizable resources in a BamlLocalizationDictionary.


Namespace:  System.Windows.Markup.Localizer
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: Not mapped to an xmlns.

public class BamlLocalizableResourceKey

The BamlLocalizableResourceKey type exposes the following members.

Public methodBamlLocalizableResourceKeyInitializes a new instance of the BamlLocalizableResourceKey class with the supplied Uid, class name, and property name.

Public propertyAssemblyNameGets the name of the assembly that defines the type of the localizable resource as declared by its ClassName.
Public propertyClassNameGets the class name component of this BamlLocalizableResourceKey.
Public propertyPropertyNameGets the property name component of this BamlLocalizableResourceKey.
Public propertyUidGets the Uid component of this BamlLocalizableResourceKey.

Public methodEquals(BamlLocalizableResourceKey)Compares two instances of BamlLocalizableResourceKey for equality.
Public methodEquals(Object)Compares an object to an instance of BamlLocalizableResourceKey for equality. (Overrides Object.Equals(Object).)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeReturns an integer hash code representing this instance. (Overrides Object.GetHashCode().)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

This class represents a key that can uniquely identify a localizable value inside binary XAML (BAML). It represents a combination of a Uid, class name, and property name.

The Uid value must be added to the source Extensible Application Markup Language (XAML) file either by using the updateuid Microsoft build engine (MSBuild) target (for example, msbuild /t:updateuid myproj.proj), or manually in the markup. BAML without a Uid cannot be localized. The class name is the type name of the element that contains the localizable property. The property name refers to the property that has the localizable value. A special property called "$Content" is used to represent values that are the initialization text or content property of an element. For example the $Content property name would apply to the initialization text Click in the following XAML:

<TextBlock x:Uid="myBlock">Click </TextBlock>

The following example demonstrates how to use a BamlLocalizableResourceKey.

// Obtain the BAML stream.
Stream source = entry.Value as Stream;

// Create a BamlLocalizer on the stream.
BamlLocalizer localizer = new BamlLocalizer(source);
BamlLocalizationDictionary resources = localizer.ExtractResources();

// Write out all the localizable resources in the BAML.
foreach (DictionaryEntry resourceEntry in resources)
    BamlLocalizableResourceKey key = resourceEntry.Key as BamlLocalizableResourceKey;
    BamlLocalizableResource value = resourceEntry.Value as BamlLocalizableResource;
        "    {0}.{1}.{2} = {3}",

.NET Framework

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.