TextPatternRange.GetAttributeValue(AutomationTextAttribute) 메서드

정의

전체 텍스트 범위에서 지정된 특성 값을 반환합니다.

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

매개 변수

attribute
AutomationTextAttribute

텍스트 특성입니다.

반환

지정된 특성의 값을 반환합니다. 예를 들어 GetAttributeValue(TextPattern.FontNameAttribute)는 텍스트 범위에 글꼴이 하나만 사용되는 경우 해당 글꼴 이름을 나타내는 문자열을 반환하는 반면 GetAttributeValue(TextPattern.IsItalicAttribute)는 부울 값을 반환합니다.

지정된 특성의 값이 텍스트 범위에서 일정하지 않게 변화하면 MixedAttributeValue를 반환합니다.

지정된 특성을 공급자 또는 컨트롤에서 지원하지 않으면 NotSupported를 반환합니다.

예외

지정된 특성이 유효하지 않은 경우

예제

 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

설명

숨겨진 / 표시 텍스트에 차이가 없습니다 있습니다. UI 자동화 클라이언트가 사용할 수 IsHiddenAttribute 텍스트 표시 여부를 확인 합니다.

적용 대상