Share via


FrameworkElement.Language Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

Namespace:  System.Windows
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
Public Property Language As XmlLanguage
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".

Remarks

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 Silverlight-based application goes considerably beyond the Language property and how you set it. This is particularly true for XAML. For more information, see Localizing Silverlight-based Applications.

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. See "Displaying Chinese, Japanese, and Korean Text" section in Localizing Silverlight-based Applications.

Where Language Values Apply

A value (including the inherited value) for Language has a potential effect on the following core Silverlight 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.

Other FrameworkElement derived classes that are not in the Silverlight core set (types not in System.Windows assembly) might also use a Language value to influence the behavior. For example, a control that is distributed in current or future versions of the Silverlight controls toolkit might have behavior that relies on Language. This might be noted in the Remarks for such a class or perhaps for specific properties of the class that are related to a behavior.

In general, Silverlight has fewer behaviors that rely on Language than does WPF. WPF supports Language influenced features such as number substitution and hyphenation that are not currently enabled in the core or SDK-distributed assemblies for Silverlight.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.