# Automate a WPF application

## Introduction

When you capture control inside Tab Control, Leapwork captures the entire window/entire tab/parent.

## Resolution

In few cases, when you capture control inside Tab Control, Leapwork captures the parent control instead of child control. This happens when control template is not defined as per guidelines for WPF control.

To define the control template, you should ensure that your template matches the defined standard template. The template should have the _TabControl_ class that defines a template part called _PART\_SelectedContentHost_, of type _ContentPresenter_.

## Template

```xml
<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

<Style x:Key="EmptyTabControlStyle" TargetType="{x:Type TabControl}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <ContentPresenter Name="PART\_SelectedContentHost" ContentSource="SelectedContent"/>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
```

**Note**: _Name="PART\_SelectedContentHost"_ is mandatory for the template to identify the control.

For more information, see [TabControl Styles and Templates](https://learn.microsoft.com/en-us/dotnet/desktop/wpf/controls/tabcontrol-styles-and-templates?view=netframeworkdesktop-4.8).

For any clarification, contact our [Priority Support](mailto:prioritysupport@leapwork.com).
