この問題をできる限り単純化しました。以下のコードを「test.linq」ファイルにカット アンド ペーストして、LinqPad にロードできます。現状では、このコードを LinqPad で実行すると、動作することが示されます。意図はtabPage1
、UI オートメーション フレームワークを使用して、AutomationId を持つペインを見つけることです。
作業中の行をコメントアウトして、破線を入れます。現在、タブ ページが見つかりません... 唯一の違いは、タブ ページがText
プロパティで宣言されていることです。
障害が自動化プロバイダーにあることを示している可能性のある一連のブログを見つけましたが、ソースを逆コンパイルしたところ、これが事実であることがわかりませんが、ベースはハンドラーを実装しており、実際にはそうではありませんそれがどこにつながるかを確認してください。TabControl
TabControl
Control
WM_GETOBJECT
何か案は?
<Query Kind="Statements">
<Reference><RuntimeDirectory>\WPF\UIAutomationClient.dll</Reference>
<Reference><RuntimeDirectory>\wpf\UIAutomationProvider.dll</Reference>
<Reference><RuntimeDirectory>\wpf\UIAutomationTypes.dll</Reference>
<Reference><RuntimeDirectory>\Accessibility.dll</Reference>
<Reference><RuntimeDirectory>\wpf\WindowsBase.dll</Reference>
<Reference><RuntimeDirectory>\System.Windows.Forms.dll</Reference>
<Reference><RuntimeDirectory>\System.Security.dll</Reference>
<Reference><RuntimeDirectory>\System.Configuration.dll</Reference>
<Reference><RuntimeDirectory>\System.Deployment.dll</Reference>
<Reference><RuntimeDirectory>\System.Runtime.Serialization.Formatters.Soap.dll</Reference>
<Namespace>System.Windows.Automation</Namespace>
<Namespace>System.Windows.Forms</Namespace>
</Query>
var tabControl = new TabControl();
tabControl.Name = "tabControl";
// Broken
//tabControl.TabPages.Add(new TabPage() { Name = "tabPage1", Text = "First Tab" });
// Working
tabControl.TabPages.Add(new TabPage() { Name = "tabPage1" });
var form = new Form() { Name = "Form1" };
form.Controls.Add(tabControl);
form.Show();
var desktop = AutomationElement.RootElement;
var frmTest = desktop.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.AutomationIdProperty, "Form1"));
var tabPage1 = frmTest.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "tabPage1"));
tabPage1.Dump("tabPage1");