WPF, Project White and Infragistics

点点圈 提交于 2019-12-05 19:58:24

Bit of a generic answer I'm afraid, but if White isn't helping you, you can use Microsoft UI Automation directly.

First, find your control. If it's got a WPF "Name" then it probably has an automation id which matches the name:

AutomationElement element = AutomationElement.Root.FindFirst(
    TreeScope.Descendants,
    new PropertyCondition(AutomationElement.AutomationIdProperty, <whatever>))

Alternatively you can use things like the NameProperty, which mostly maps to text or titles, or the ControlTypeProperty or ClassProperty. You can always use FindAll to give you more information about the controls available.

When you find your control, print out its supported patterns and properties:

element.GetSupportedPatterns()
element.GetSupportedProperties()

The properties give back information. The patterns are things like ListItemPattern, GridPattern and let you access more component-specific values. You may find a pattern or property which gives you what you need. White is partly built on top of this, so it might help you find out which White components you could use. For instance:

((TogglePattern)Element.GetCurrentPattern(TogglePattern.Pattern)).Toggle()

Snoop is an app which can help you get this information without going through the print-outs: http://snoopwpf.codeplex.com/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!