如何使用 DataTemplate 刷新 WPF AutomationElement - Windows UI 自动化 [英] How to refresh WPF AutomationElement with DataTemplate - Windows UI Automation

查看:27
本文介绍了如何使用 DataTemplate 刷新 WPF AutomationElement - Windows UI 自动化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Windows UI 自动化.

该应用程序有一个 ContentControl 带有根据用户交互而变化的数据模板.

The application has a ContentControl with a data template that changes based on user interaction.

在初始加载时,我能够获取并单击内容控件内的按钮.这会切换数据模板(删除子控件并替换为其他控件).

On initial load, I am able to get and click a button inside of the content control. This switches the data template (the sub-controls are removed and replaced with other ones).

但是,当我在自动化元素中查找新控件时,却找不到.

However, when I look for the new controls in the automation element, they cannot be found.

我正在使用包装器 FlaUI,但我也尝试过 White 并且它们都具有相同的结果.

I am using the wrapper FlaUI, but I've also tried White and they both have the same sort of result.

我没有使用缓存,但窗口似乎以某种方式缓存了.有没有办法重新加载元素或整个窗口,以便我可以检索新控件.

I am not using caching, but it seems like the window is somehow cached. Is there a way to reload the element or entire window so that I can retrieve the new controls.

推荐答案

FlaUI 的常见问题解答.

在使用 DevExpress 控件时,有些东西(如标签内容)不是更新默认情况下,DevExpress 控件不会提高自动化事件,因为这些事件可能会降低应用程序的性能.到确保事件正确引发,设置ClearAutomationEventsHelper.IsEnabled 静态属性设置为 false应用程序启动(需要在应用程序中完成)使用 FlaUI 自动化):

When using DevExpress controls, some things (like tab content) are not updated By default, DevExpress controls do not raise automation events, as these events may decrease the application performance. To make sure that the events are raised properly, set the ClearAutomationEventsHelper.IsEnabled static property to false on application startup (needs to be done in the application that is automated with FlaUI):

ClearAutomationEventsHelper.IsEnabled = false;

ClearAutomationEventsHelper.IsEnabled = false;

这篇关于如何使用 DataTemplate 刷新 WPF AutomationElement - Windows UI 自动化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆