【问题标题】:AutomationElement get real TypeAutomationElement 获取真实类型
【发布时间】:2012-09-19 06:53:37
【问题描述】:

如何获得AutomationElement的真实Type(例如TextEdit等)? GetType() 返回System.Windows.Automation.AutomationElement

【问题讨论】:

  • 试试 element.Current.ClassName ? - 它仅适用于某些框架;例如。为 Win32 列表视图返回 SysListView32。由每个框架决定如何使用它,我不认为 WPF 在这里公开任何有用的东西。

标签: c# wpf .net-4.0 ui-automation


【解决方案1】:

您可以通过AutomationElement.Current.ControlType 属性获取自动化元素的类型。

ControlType controlType = AutomationElement.Current.ControlType;

欲了解更多信息,请参阅MSDN

【讨论】:

  • 它返回 System.Windows.Automation.ControlType.... 而不是 DevExpress 的 TextEdit...
  • @ArtemMakarov 我真的希望这对您来说不再是问题。我怎么也遇到过同样的问题。这就是我获得正确类型的方式:AutomationElement.Current.ControlType.ProgrammaticName
【解决方案2】:

我尝试并发现以下工作:

DirectCast(<AutoElementName>.GetCurrentPropertyValue(AutomationElement.ControlTypeProperty), ControlType).LocalizedControlType

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-05-21
    • 1970-01-01
    • 2016-01-17
    • 2011-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多