TextPatternRange.FindAttribute 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
지정된 특성 값이 있는 텍스트 범위 하위 집합을 반환합니다.
public:
System::Windows::Automation::Text::TextPatternRange ^ FindAttribute(System::Windows::Automation::AutomationTextAttribute ^ attribute, System::Object ^ value, bool backward);
public System.Windows.Automation.Text.TextPatternRange FindAttribute(System.Windows.Automation.AutomationTextAttribute attribute, object value, bool backward);
member this.FindAttribute : System.Windows.Automation.AutomationTextAttribute * obj * bool -> System.Windows.Automation.Text.TextPatternRange
Public Function FindAttribute (attribute As AutomationTextAttribute, value As Object, backward As Boolean) As TextPatternRange
매개 변수
- attribute
- AutomationTextAttribute
검색할 특성입니다.
- value
- Object
검색할 특성 값입니다. 이 값은 특성에 지정된 형식과 일치해야 합니다.
- backward
- Boolean
true 마지막으로 발생한 텍스트 범위가 첫 번째 텍스트 범위 대신 반환되어야 하면 이고, 그렇지 않으면 false.
반품
일치하는 특성 및 특성 값이 있는 텍스트 범위입니다. 그렇지 않으면 null입니다(Nothing Visual Basic).
예제
private TextPatternRange RangeFromAttribute(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[] currentSelelction = textpatternPattern.GetSelection();
// Find 'italic' range
return currentSelelction[0].FindAttribute(TextPattern.IsItalicAttribute, true, false);
}
Private Function RangeFromAttribute(ByVal target As AutomationElement) As TextPatternRange
' 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()
Return currentSelection(0).FindAttribute(TextPattern.IsItalicAttribute, True, False)
End Function
설명
숨겨진 텍스트와 표시되는 텍스트는 구분되지 않습니다. UI 자동화 클라이언트는 IsHiddenAttribute 사용하여 텍스트 표시 여부를 확인할 수 있습니다.
메모
전체 문서를 검색하는 데 사용합니다 DocumentRange .