Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1042921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:35:05+00:00 2026-05-16T15:35:05+00:00

Summary In my WPF application, I needed a TabControl with buttons on the left,

  • 0

Summary

In my WPF application, I needed a TabControl with buttons on the left, so I defined a ControlTemplate with the layout I wanted and it worked fine.

However, my tester’s automated testing tool can’t see any of the content of the tabs, including the currently selected tab.

Question: How can I keep my TabControl testable by the automated testing tools, while still defining the ControlTemplate?


Details

I’m developing a WPF application using WPF 3.5
My tester is using an automated test tool called QTP
He says he can test anything you can see with UISpy.exe

  • When I use a straight TabControl with no Template applied, UISpy can see the content of the currently selected tab.
  • However, when I use a ContentTemplate to change the layout (code shown below), UISpy can still see the tab headers… but it cannot see the content.

Sample WPF application (Xaml):

<Window x:Class="TabControlTest.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Tab Control Test"
        Height="300"
        Width="300">
    <Window.Resources>
        <ControlTemplate x:Key="ButtonsOnLeftTabLayout"
                         TargetType="{x:Type TabControl}">
            <DockPanel>
                <StackPanel DockPanel.Dock="Left"
                            IsItemsHost="True" />
                <ContentPresenter Content="{TemplateBinding SelectedContent}" />
            </DockPanel>
        </ControlTemplate>
    </Window.Resources>
    <TabControl Template="{StaticResource ButtonsOnLeftTabLayout}">
        <TabItem Header="Tab 1">
            <StackPanel>
                <Button HorizontalAlignment="Center">Button 1</Button>
            </StackPanel>
        </TabItem>
        <TabItem Header="Tab 2">
            <StackPanel>
                <Button HorizontalAlignment="Center">Button 2</Button>
            </StackPanel>
        </TabItem>
    </TabControl>
</Window>

What my search has found so far:

  • A bunch of stuff about having to write a custom TabControl with a custom AutomationPeer (e.g. MSFT answer to forum question UI Automation: accessing control in a ControlTemplate, blog posting Custom Controls and UI Automation). But my every instinct says that’s crazy overkill, “there must be a simpler way!”
  • Some suggestions about giving the ContentPresenter a Name, or x:Name, or AutomationProperties.AutomationId — none of which have any effect

(After search I finally found answer but it took longer than I thought it should have, and the AutomationPeer early findings were indeed incorrect, so I’m writing this as a SO question and self-answer, in case it helps anyone else in future)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T15:35:06+00:00Added an answer on May 16, 2026 at 3:35 pm

    Found answer in a different MSFT response on a different but similar msdn forum question, TabControl controls are missing for UI Automation.

    To get the UI Automation working for ContentTemplated TabControl, add Name=”PART_SelectedContentHost” attribute to the ContentPresenter, like this

    <ContentPresenter Name="PART_SelectedContentHost"
                      Content="{TemplateBinding SelectedContent}"/>
    

    That’s all it takes. UISpy can now see the content of the currently selected tab.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.