Edit

Share via


AutomationElement.LabeledByProperty Field

Definition

Identifies the LabeledBy property, which identifies the label associated with a control.

public: static initonly System::Windows::Automation::AutomationProperty ^ LabeledByProperty;
public static readonly System.Windows.Automation.AutomationProperty LabeledByProperty;
 staticval mutable LabeledByProperty : System.Windows.Automation.AutomationProperty
Public Shared ReadOnly LabeledByProperty As AutomationProperty 

Field Value

Examples

The following example retrieves the current value of the property. The default value is returned if the element does not provide one.

AutomationElement labeler =
    autoElement.GetCurrentPropertyValue(AutomationElement.LabeledByProperty) as AutomationElement;
Dim labeler As AutomationElement = _
    DirectCast(autoElement.GetCurrentPropertyValue(AutomationElement.LabeledByProperty), _
    AutomationElement)

The following example retrieves the current value of the property, but specifies that if the element itself does not provide a value for the property, NotSupported is to be returned instead of a default value.

AutomationElement labeler1;
object labelerNoDefault =
    autoElement.GetCurrentPropertyValue(AutomationElement.LabeledByProperty, true);
if (labelerNoDefault == AutomationElement.NotSupported)
{
    // TODO Handle the case where you do not wish to proceed using the default value.
}
else
{
    labeler1 = labelerNoDefault as AutomationElement;
}
Dim labeler1 As AutomationElement
Dim labelerNoDefault As Object = autoElement.GetCurrentPropertyValue(AutomationElement.LabeledByProperty, True)
If labelerNoDefault Is AutomationElement.NotSupported Then
    ' TODO Handle the case where you do not wish to proceed using the default value.
Else
    labeler1 = DirectCast(labelerNoDefault, AutomationElement)
End If

Remarks

This identifier is used by UI Automation client applications. UI Automation providers should use the equivalent identifier in AutomationElementIdentifiers.

This property can also be retrieved from the Current or Cached properties.

Return values of the property are of type AutomationElement. The default value for the property is null.

Applies to

See also