2

UI オートメーション フレームワークを介して WPF UserControl DependencyProperty 値にアクセスできません。

MSDN の James McCaffrey の記事 (Automating IO Tests in WPF Applications, MSDN March 2009) を出発点として使用しましたが、ボタンなどの標準コントロールのプロパティなどしか表示できません。

UserControl に実装しなければならない Automation インターフェイスがあると仮定していますが、何をどのように実装するのでしょうか?

UISpy などでコントロールを正常に表示できますが、その中に依存関係のプロパティが表示されません。UISpy での現在のユーザー コントロールの外観は次のとおりです。

AutomationElement General Accessibility AccessKey: "" AcceleratorKey: "" IsKeyboardFocusable: "False" LabeledBy: "(null)" HelpText: "48v ファンタム電源のオン/オフを切り替えます (マイク入力のみ)。"

状態 IsEnabled: "True" HasKeyboardFocus: "False"

識別 ClassName: "" ControlType: "ControlType.Custom" Culture: "(null)" AutomationId: "V48SwL" LocalizedControlType: "custom" Name: "" ProcessId: "5684 (VirtualSix)" RuntimeId: "7 5684 40026340" IsPassword: "False" IsControlElement: "True" IsContentElement: "True"

Visibility BoundingRectangle: "(140, 457, 31, 20)" ClickablePoint: "155,467" IsOffscreen: "False"

コントロールパターン

4

1 に答える 1

2

UI オートメーションから任意の Dependency Property 値を取得する方法はありません。取得できるのはAutomationProperty値のみです。

このフォーラムの投稿によると、UIAutomation API の新しいバージョンには独自のカスタム AutomationProperties を追加する方法がありますが、そのバージョンの UIA はまだ WPF でサポートされていません。

推奨される回避策は、関心のある Dependency Property を AutomationProperties.ItemStatus 添付プロパティにバインドすることです。これは、AutomationElement.Current.ItemStatus で使用できるようになります。

于 2010-03-12T12:31:12.217 に答える