Make sure Codeduitest is able to identify element inside a Hidden TabItem

Recently there was a customer who reported an issue (Details https://social.msdn.microsoft.com/Forums/en-US/vsautotest/thread/e977a27a-bb67-4919-af84-1d06ce891047/).

In his application there was a TabItem who's Visibility property was set to Collapsed. Due to this AutomationElement.FromPoint (UIA api) was not able to return correct element(inside the hidden tabitem) from point (and hence codeduitest test was not able to recognize element from point). This looks like some optimization which WPF UIA implementation has when drilling down for element from point.

The workaround is to override the default TabItemAutomationPeer implementation and override few properties so that the drilling works fine. Attached is the custom TabItem class which I wrote to make this possible. You just need to use the TabItemCustom class instead of default TabItem class to achieve this. TabItemCustomPeer is the automationpeer implementation of TabItemCustom. TabItemCustomPeer is the important class which made this possible.

TabItemCustom (2).cs