카테고리 없음
[씨#] TreeWalker는 다른 창에서 컨트롤을 탐색합니다.
행복을전해요
2021. 2. 18. 20:54
사실 저는 TreeWalker가 왜 그렇게하는지 말할 수 없습니다. 저는 TreeWalker를 탐색에 사용하지 않기 때문입니다. 나는 부모, 자녀, 치찰음 등을 찾는 데 사용합니다.
제가 말할 수있는 것은 다음을 사용하는 데 매우 좋은 경험이 있다는 것입니다.
List<AutomationElement> messages = new List<AutomationElement>();
AutomationElement parentDatagrid;//your AE
Condition yourCond = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.DataItem));
AutomationElementCollection aECollection;
aECollection= parentDatagrid.FindAll(TreeScope.Element | TreeScope.Descendants, yourCond);
foreach (AutomationElement element in aECollection)
{
//whatever you like
}
물론 성능이 문제가되는 경우 TreeScope.Descendants에주의해야합니다. 그런 다음 Descendants는 모든 하위 요소를 확인하고 Children은 직계 하위 요소 만 확인하므로 TreeScope.Children을 대신 고려해야합니다.
도움이 되었기를 바랍니다!
-------------------사용자 지정을 만들면 TreeWalker
언급 한대로 동작합니다. a를 사용한 TreeWalker.ControlViewWalker
다음 검색된 각 요소에서 조건을 확인 하는 것이 좋습니다 .
출처
https://stackoverflow.com/questions/22079871