EN
Ce contenu n’est pas disponible dans votre langue. Voici la version anglaise.

FrameworkElement.Language Property

May 11, 2014

Gets or sets localization/globalization language information that applies to a FrameworkElement.

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

public XmlLanguage Language { get; set; }
<frameworkElement Language="languageString"/>
-or-
<frameworkElement Language="reference"/>

XAML Values

languageString

A string specifying language and culture that follows the RFC 3066 / ISO 639-1 standards. For example, U.S. English is "en-US". For more information about the values and format, see XmlLanguage.

reference

A reference technique such as Binding or StaticResource that avoids hard-coding the Language value. See Remarks.

Property Value

Type: System.Windows.Markup.XmlLanguage
The language information for this object. The default is an XmlLanguage object that has its IetfLanguageTag value set to the string "en-US".

Dependency property identifier field: LanguageProperty

The string formats follow the RFC 3066 / ISO 639-1 standards. For example, U.S. English is "en-US". For more information about the values and format, see XmlLanguage.

Language is generally equivalent to the XML-defined attribute xml:lang and provides a bridge for xml:lang as found in markup into the managed API and object tree. Language also deliberately uses a property inheritance structure so that a value for Language set on the root element will propagate that value to all child objects in the visual tree. This parallels the xml:lang behavior in XML and the XML DOM.

Developing a localizable application goes considerably beyond the Language property and how you set it. This is particularly true for XAML..

As a best practice for most scenarios, if you set Language at all, you should consider one or both of the following:

  • Set Language only on the root element. (An exception to this is if you are deliberately attempting to support multiple locale conventions for text display on a single page. For example, you might be writing a translator application where separate TextBox elements have different Language values.)

  • Rather than hard-code the value with a string in XAML in individual XAML files, set it with a resource and/or a binding so that you can centralize XAML localization needs in a handful of resources or other localizable files.

Where Language Values Apply

A value (including the inherited value) for Language has a potential effect on the following core Windows Phone objects: PasswordBox, TextBox, TextBlock. The Language is used by the font subsystem to determine the default font if no specific FontFamily value is specified for these objects. For more information, see Text and fonts for Windows Phone.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Afficher:
© 2014 Microsoft