Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
15
Can't find content of TabItemEx in Inspect.exe
posted

We're trying to write Automated UI tests for an application which uses TabItemEx to display its functionality, however we're not able to traverse the UI Element Tree (with Inspect.exe) into the content of a TabItemEx. The content is not visible with tools such as Inspect.exe and FlaUInspect.exe, but is visible with the Live Visual Tree is Visual Studio and Snoop.

<Custom:XamTabControl x:Name="mainTabs" IsEnabled="{Binding IsInitialized}"
                Style="{DynamicResource ApplicationTabs}" AutomationProperties.Name="mainTabs" >
            <Custom:TabItemEx x:Name="homeTab" AutomationProperties.AccessKey="homeTabAccessKey">
                <Custom:TabItemEx.Header>
                    <StackPanel Orientation="Horizontal">
                        <Viewbox Width="16" Height="16">
                            <ContentPresenter ContentTemplate="{DynamicResource Home}"></ContentPresenter>
                        </Viewbox>
                        <TextBlock Text="{local:Localize home}" FontWeight="Bold" Margin="5,0,0,0"></TextBlock>
                    </StackPanel>
                </Custom:TabItemEx.Header>
                <view:HomeControl AutomationProperties.AutomationId="homeControl" />
            </Custom:TabItemEx>
</Custom:XamTabControl>

The content we're trying to reach is the homeControl. We've discovered that, if placed inside the TabItemEx.Header tag, the homeControl becomes reachable through automated UI tests. 

Parents
  • 33370
    Offline posted

    Hello Alexander,

    I have been investigating into the behavior you are seeing, and when the “HomeControl” is placed as the Content of a tab, it actually goes into the visual tree of the XamTabControl and not the TabItemEx. It is essentially bound to the ContentPresenter that is in the visual tree of the XamTabControl when the corresponding tab is selected. The Microsoft TabControl exhibits the same behavior.

    If you are looking to reach the HomeControl in the case of the code you have provided, I would recommend that you search the visual tree of the XamTabControl rather than the TabItemEx, but only when the corresponding TabItemEx is the selected tab, as the HomeControl will not be in the visual tree when other tabs are selected.

    Please let me know if you have any other questions or concerns on this matter.

Reply Children
No Data