AutomationProperties.LabeledBy Attached Property
This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Gets or sets the element that contains the text label for the element.
Namespace: System.Windows.Automation
Assembly: System.Windows (in System.Windows.dll)
Syntax
See GetLabeledBy, SetLabeledBy
See GetLabeledBy, SetLabeledBy
XAML Values
- labelElement
The Name or x:Name of a control or text element that labels this control. Typically, this element is a TextBlock.
Property Value
Type: System.Windows..::.UIElement
The element that contains the text label for the element.
Remarks
The most common way to set this attached property is through either 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. For more information, see ElementName, or Data binding for Windows Phone 8.
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.
You could also use code to set this attached property value. Call SetLabeledBy, passing the element being labeled as the first parameter and a reference to the label as the second parameter. 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. Otherwise, you might need to add a handler at the page level for LayoutUpdated in order to apply the various LabeledBy values to the XAML-generated UI.
XAML Attribute Usage
<object AutomationProperties.LabeledBy="{Binding ElementName=labelElement}"/>
Version Information
Windows Phone OS
Supported in: 8.1, 8.0, 7.1, 7.0
Platforms
Windows Phone