TextPatternRange.GetAttributeValue(AutomationTextAttribute) 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
전체 텍스트 범위에서 지정된 특성의 값을 반환합니다.
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 사용하여 텍스트 표시 여부를 확인할 수 있습니다.