AutomationProperties.LabeledBy attached property

Applies to Windows and Windows Phone

Gets or sets the element that contains the text label for the element.


<object AutomationProperties.LabeledBy="referenceToElement" />

XAML Values

referenceToElement

A binding reference to the element that is this element's designated label. The binding reference is typically made in the form {Binding ElementName=nameHere}, where nameHere is the Name or x:Name of the labeling element. For this usage to work, the element name lookup must be able to use the default data context.

Remarks

AutomationProperties.LabeledBy is an attached property, which supports a XAML usage. When getting this property in code, use GetLabeledBy. When setting this property in code, use SetLabeledBy instead. In code usages, the target parameter is the object where the attached property value is set. Another way to get or set the value in code is to use the dependency property system, calling either GetValue or SetValue and passing LabeledByProperty as the dependency property identifier.

The purpose of AutomationProperties.LabeledBy and the AutomationProperties attached properties is to provide instance values for behavior that are not already present or defined in the control definition or a control's applied generic template.

The most common way to set this attached property is through an ElementName binding. An ElementName binding is a Binding declaration that specifies another element in the UI by name, passing that name to the ElementName attribute or property of the binding declaration.

A TemplateBinding associates a value of the templated control with some property within the template's definition structure. This might be used if the templated control has a dedicated property for tracking label associations. If you are declaring control composition in a template, and you are the control author, you could make this call part of your OnApplyTemplate handling.

For more information on data binding concepts, including ElementName binding, see Quickstart: Data binding to controls.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Automation

Metadata

Windows.winmd

See also

AutomationProperties

 

 

Show:
© 2014 Microsoft