WPF UI 自动化 - 在单击 TabControl 区域之前,控件树不会被填充

发布于 2024-11-26 15:45:08 字数 230 浏览 2 评论 0原文

我正在使用 Microsoft UI 自动化库为 WPF 应用程序执行 UI 自动化,效果很好。

然而,我的应用程序在 TabControl 中有四个屏幕。即使当我通过代码单击选项卡项时,其子控件树也不会填充。我能看到的唯一控件是“拇指”控件。当我用 UISpy 查看控制树时,也会发生同样的情况。

但是,如果单击该窗口,则会出现所有控件。作为解决方法,我通过代码模拟鼠标单击并且它有效。我想知道是否有更好的方法。

I am doing a UI automation for a WPF application using the Microsoft UI Automation library and it works well.

However my app has four screens in a TabControl. Even when I click the tab item through code its child control tree isnt populated. The only control I can see is the "thumb" Control. Same happens when I see the control tree with UISpy.

However if the window is clicked then all the controls appear. As a Workaround I am simulating a mouseclick through code and it works. I wanted to know if there is some better way of doing it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

世界如花海般美丽 2024-12-03 15:45:08

我遇到了类似的问题。发生的情况是在线程上检索一些数据,并且在生成自动化对等点时未生成控件。我建议,如果您有权访问应用程序的代码库,您将尝试自动检查是否正在使用线程。在我的具体情况下,这是因为 BeginInvokes 用于检索数据,我将它们切换到 Invokes 并且工作正常。

另外,据我所知,鼠标悬停时显示控件的原因是工具提示生成了弹出窗口并导致自动化对等点更新。

I ran into a problem similar to this. What was happening was some data was being retrieved on threads and the controls were not generated at the point automation peers were generated. I would suggest if you have access to the code base for the application you are attempting to automate looking into whether threading is being used. In my specific case it was because BeginInvokes were used to retrieve the data, I switched them to Invokes and it worked fine.

Also from what I could tell the reason the controls were being show on mouse over was because the tool tip generated a popup and caused the automation peers to be updated.

九命猫 2024-12-03 15:45:08

如果可行的话,为什么不使用鼠标事件单击控件呢?

(现在,如果您仍然遇到这个问题..)

如何模拟鼠标点击在 C# 中?

Why don't you click the control using mouse events if that is what works.

(Now, if you still are having that problem..)

How to simulate Mouse Click in C#?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文