我无法通过 UI 自动化框架访问我的 WPF UserControl DependencyProperty 值。
我以 MSDN 中的 James McCaffreys 文章作为起点(Automating IO Tests in WPF Applications,MSDN March 2009),但我只能在标准控件(如按钮)中查看属性等。
我假设我必须在我的 UserControl 上实现一些自动化接口,但是什么以及如何实现?
我已经可以很好地看到我的控件,例如在 UISpy 中,但是我看不到其中的依赖属性。这是我的用户控件当前在 UISpy 中的样子:
AutomationElement 通用辅助功能 AccessKey:“”AcceleratorKey:“”IsKeyboardFocusable:“False”LabeledBy:“(null)”HelpText:“开关48v幻象电源开/关(仅用于麦克风输入)。”
状态 IsEnabled:“True” HasKeyboardFocus:“False”
标识 ClassName:“”ControlType:“ControlType.Custom”Culture:“(null)”AutomationId:“V48SwL”LocalizedControlType:“custom”名称:“”ProcessId:“5684(VirtualSix)”RuntimeId:“7 5684 40026340”IsPassword: “假” IsControlElement:“真” IsContentElement:“真”
Visibility BoundingRectangle: "(140, 457, 31, 20)" ClickablePoint: "155,467" IsOffscreen: "False"
控制模式