Unable to cast a WPF window to Core.UIItems.WindowItems.Window

Apr 22, 2009 at 3:03 PM

Hello,

I am trying to cast a window which is derived from a WPF window to Core.UIItems.WindowItems.Window. The compiler takes very long time when it reaches the casting, that I have to break running the test.

SearchCriteria sc = SearchCriteria.ByText("TestWindow");

Core.UIItems.WindowItems.Window win =    (Core.UIItems.WindowItems.Window)Desktop.Instance.Get(sc);

 

I have tried to cast the window to a UIItem and it works. The problem is that if I search for an item in this UIItem (window), the search result is always null.

SearchCriteria sc = SearchCriteria.ByText("TestWindow");

UIItem win = (UIItem)Desktop.Instance.Get(sc);

 

AutomationElement ae = win.AutomationElement.FindFirst(TreeScope.Descendants , new PropertyCondition(AutomationElement.AutomationIdProperty, "ComboBox") );

 

ae is always null.

 

Any Idea?

Coordinator
May 25, 2009 at 6:18 AM

Is there a reason you are not using Application.GetWindow instead using Desktop to find your window?