Localization 类


Localization 类为本地化特性和注释定义附加属性。The Localization class defines attached properties for localization attributes and comments.

public ref class Localization abstract sealed
public static class Localization
type Localization = class
Public Class Localization


下面的代码示例演示为文本块定义的本地化特性和注释。The following code example shows localization attributes and comments defined for a text block.

<!-- Define localization attributes and comments for the text block.
    - The content is visible to the localizer and can be changed.
    - The font size property is visible to the localizer and can be changed.
    - The comment specifies that the trademark font size should be used. -->
    "$Content(Text Readable Modifiable) FontSize(Font Readable Modifiable)"
    "$Content(Trademark) FontSize(Trademark font size)" >
  your company name here


标记作者可能对 UI 中可扩展应用程序标记语言 (XAML)Extensible Application Markup Language (XAML)的元素有特定要求, 例如文本长度、字体系列或字号的约束。Markup authors may have specific requirements for elements in 可扩展应用程序标记语言 (XAML)Extensible Application Markup Language (XAML) UI, such as constraints for text length, font family, or font size. 本地化人员需要了解这些信息, 以便提供一致的本地化。Localizers need to know about them in order to provide consistent localization. 可以在内部可扩展应用程序标记语言 (XAML)Extensible Application Markup Language (XAML)指定本地化属性, 使作者能够将其本地化需求传达给本地化人员。Localization properties can be specified inside 可扩展应用程序标记语言 (XAML)Extensible Application Markup Language (XAML), allowing authors to communicate their localization needs to localizers. 这些属性提供了可用于修改应用程序的本地化规则和提示。These properties provide rules and hints for localization, which can be used to modify the application. 本地化属性有两种类型:There are two types of localization properties:

  • 本地化特性。Localization attributes. 特性指定将本地化哪些资源, 如FontFamilyThe attributes specify which resources, such as FontFamily, are to be localized.

  • 本地化注释。Localization comments. 注释是标记作者包含的自由格式文本。The comments are free-form text that the markup author includes.

有关如何使用这些本地化属性的详细信息, 请参阅本地化特性和注释For more information on how to use these localization properties, see Localization Attributes and Comments.



标识 Attributes 附加属性。Identifies the Attributes attached property.


标识 Comments 附加属性。Identifies the Comments attached property.



从指定元素获取 AttributesProperty 附加属性的值。Gets the value of the AttributesProperty attached property from a specified element.


从指定元素获取 CommentsProperty 附加属性的值。Gets the value of the CommentsProperty attached property from a specified element.

SetAttributes(Object, String)

为指定元素设置 AttributesProperty 附加属性。Sets the AttributesProperty attached property for the specified element.

SetComments(Object, String)

CommentsProperty 附加属性设置为指定元素。Sets the CommentsProperty attached property to the specified element.