Taal

TextPatternRange.GetAttributeValue(AutomationTextAttribute) Methode

Definitie

Retourneert de waarde van het opgegeven kenmerk in het hele tekstbereik.

public:
 System::Object ^ GetAttributeValue(System::Windows::Automation::AutomationTextAttribute ^ attribute);
public object GetAttributeValue(System.Windows.Automation.AutomationTextAttribute attribute);
member this.GetAttributeValue : System.Windows.Automation.AutomationTextAttribute -> obj
Public Function GetAttributeValue (attribute As AutomationTextAttribute) As Object

Parameters

attribute
AutomationTextAttribute

Het tekstkenmerk.

Retouren

Retourneert de waarde van het opgegeven kenmerk. GetAttributeValue(TextPattern.FontNameAttribute) retourneert bijvoorbeeld een tekenreeks die de naam van het lettertype vertegenwoordigt, indien uniek, van het tekstbereik terwijl GetAttributeValue(TextPattern.IsItalicAttribute) een booleaanse waarde retourneert.

Retourneert als de waarde van het opgegeven kenmerk varieert MixedAttributeValue over het tekstbereik.

Retourneert NotSupported als het opgegeven kenmerk niet wordt ondersteund door de provider of het besturingselement.

Uitzonderingen

Als het opgegeven kenmerk ongeldig is.

Voorbeelden

 private Object AttributeValueFromSelection(AutomationElement target)
{
    // Specify the control type we're looking for, in this case 'Document'
    PropertyCondition cond = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document);

    // target --> The root AutomationElement.
    AutomationElement textProvider = target.FindFirst(TreeScope.Descendants, cond);

    TextPattern textpatternPattern = textProvider.GetCurrentPattern(TextPattern.Pattern) as TextPattern;

    if (textpatternPattern == null)
    {
        Console.WriteLine("Root element does not contain a descendant that supports TextPattern.");
        return null;
    }
    TextPatternRange[] currentSelection = textpatternPattern.GetSelection();
    // Is 'italic'?
    return currentSelection[0].GetAttributeValue(TextPattern.IsItalicAttribute);
}
Private Function AttributeValueFromSelection(ByVal target As AutomationElement) As Object
    ' Specify the control type we're looking for, in this case 'Document'
    Dim cond As PropertyCondition = New PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Document)

    ' target --> The root AutomationElement.
    Dim textProvider As AutomationElement = target.FindFirst(TreeScope.Descendants, cond)

    Dim textpatternPattern As TextPattern = CType(textProvider.GetCurrentPattern(TextPattern.Pattern), TextPattern)

    If (textpatternPattern Is Nothing) Then
        Console.WriteLine("Root element does not contain a descendant that supports TextPattern.")
        Return Nothing
    End If
    Dim currentSelection As TextPatternRange() = textpatternPattern.GetSelection()
    ' Is 'italic'?
    Return currentSelection(0).GetAttributeValue(TextPattern.IsItalicAttribute)
End Function

Opmerkingen

Er is geen onderscheid tussen verborgen en zichtbare tekst. UI Automation clients kunnen IsHiddenAttribute gebruiken om de zichtbaarheid van tekst te controleren.

Van toepassing op