【发布时间】:2017-01-26 19:08:46
【问题描述】:
一个 WPF 应用程序正在使用一个应用程序框架,我无法编辑它们。
我可以通过以下方式访问 GUI 中的每个元素:
IUIItem[] items = window.GetMultiple(SearchCriteria.All);
foreach (var item in items)
{
visit((dynamic)item);
}
我对正常控制没有任何问题,但我用CustomUIItem 碰壁了。
我想访问它的所有孩子,但我无法从他们那里创建一个新数组IUIItem[]。
这是我现在拥有的:
void visit(CustomUIItem item)
{
AutomationElementCollection children =
item
.AutomationElement
.FindAll(TreeScope.Children, Condition.TrueCondition);
UIItemCollection temp = new UIItemCollection(children.Cast<AutomationElement>());
foreach(var t in temp)
{
visit((dynamic)t);
}
}
这有时会抛出,并且大部分时间集合仍然是空的。
CusomControl 在其子项中具有“正常”控件。
我想要那些普通的IUIItems。
我在哪里可以找到这方面的文档。 我唯一找到的是this,我不能这样做,因为我只是从外面访问,我不知道控件的内容。
【问题讨论】:
标签: c# wpf white-framework