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

  • SEARCH
  • Home
  • 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 723297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:05:31+00:00 2026-05-14T06:05:31+00:00

I have to develop a customized tab control and decided to create it with

  • 0

I have to develop a customized tab control and decided to create it with WPF/XAML, because I planned to learn it anyway. It should look like this when it’s finished:

Target

I made good progress so far, but there are two issues left:

  1. Only the first/last tab item should have a rounded upper-left/bottom-left corner. Is it possible to modify the style of these items, similar to the way I did with the selected tab item?

  2. The selected tab item should not have a border on its right side. I tried to accomplish this with z-index and overlapping, but the results were rather disappointing. Is there any other way to do this?

Current

XAML:

<Window x:Class="MyProject.TestWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="TestWindow" Height="350" Width="500" Margin="5" Background="LightGray">
<Window.Resources>
    <LinearGradientBrush x:Key="SelectedBorderBrush" StartPoint="0,0" EndPoint="1,0">
        <GradientBrush.GradientStops>
            <GradientStopCollection>
                <GradientStop Color="Gray" Offset="0.965"/>
                <GradientStop Color="WhiteSmoke" Offset="1.0"/>
            </GradientStopCollection>
        </GradientBrush.GradientStops>
    </LinearGradientBrush>
    <Style TargetType="{x:Type TabControl}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabControl}">
                    <DockPanel>
                        <Border
                            Panel.ZIndex="50"
                            Margin="0,100,-1,0" 
                            Background="#FFAAAAAA"
                            BorderBrush="Gray"
                            CornerRadius="7,0,0,7"
                            BorderThickness="1">
                            <TabPanel
                                Margin="0,0,0,0"
                                IsItemsHost="True" />
                        </Border>
                        <Border
                            Background="WhiteSmoke"
                            BorderBrush="Gray"
                            BorderThickness="1"
                            CornerRadius="7,7,7,0" >
                            <ContentPresenter 
                                ContentSource="SelectedContent" />
                        </Border>
                    </DockPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="{x:Type TabItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type TabItem}">
                    <Grid>
                        <Border Name="Border" 
                            Background="#FFAAAAAA"
                            CornerRadius="7,0,0,0"
                            BorderBrush="Gray"
                            BorderThickness="0,0,0,1"
                            Panel.ZIndex="50"
                            Margin="0,0,0,0"
                                >

                            <ContentPresenter x:Name="ContentSite"             
                                VerticalAlignment="Center"
                                HorizontalAlignment="Left"
                                ContentSource="Header"
                                Margin="10,10,10,10"/>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Panel.ZIndex" Value="100" />
                            <Setter Property="Margin" Value="0,0,-2,0" />
                            <Setter TargetName="Border" 
                                    Property="BorderBrush" 
                                    Value="{StaticResource SelectedBorderBrush}"/>
                            <Setter TargetName="Border" 
                                Property="Background" 
                                Value="WhiteSmoke" />
                            <Setter TargetName="Border" 
                                Property="CornerRadius" 
                                Value="0,0,0,0" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</Window.Resources>
<Grid>
    <TabControl Name="_menuTabControl" TabStripPlacement="Left" Margin="5">
        <TabItem Name="_tabItem1" Header="First Tab Item" ></TabItem>

        <TabItem Name="_tabItem2" Header="Second Tab Item" >
            <Grid />
        </TabItem>
        <TabItem Name="_tabItem3" Header="Third Tab Item" >
            <Grid />
        </TabItem>
    </TabControl>
</Grid>

Edit: Thanks to Vlad, I could fix the second problem with a gradient border brush. See updates XAML for the solution.

Edit: Vlad fixed the first problem.

  • 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-14T06:05:32+00:00Added an answer on May 14, 2026 at 6:05 am

    For the second problem, you should perhaps try to remove the clipping? Beware however of the possible issues.

    For the first problem, you should try style trigger on property IsSelected. (Edit: I see, you are doing it exactly this way.) Have a look how this is implemented at the default template at MSDN. Note that they are using ZIndex, too.

    Edit:
    I found a workaround for your first/last tab problem. You need to use attached properties to designate the first/last tab:

    In your TestWindow class you define attached property:

    public static bool GetIsFirstTab(DependencyObject obj)
    {
        return (bool)obj.GetValue(IsFirstTabProperty);
    }
    
    public static void SetIsFirstTab(DependencyObject obj, bool value)
    {
        obj.SetValue(IsFirstTabProperty, value);
    }
    
    public static readonly DependencyProperty IsFirstTabProperty =
            DependencyProperty.RegisterAttached("IsFirstTab", typeof(bool),
                   typeof(TestWindow), new UIPropertyMetadata(false));
    

    Then, in your first tab you set this property:

    <Window x:Class="MyProject.TestWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:local="clr-namespace:MyProject"
            ...
    />
        ...
        <TabItem Name="_tabItem1" Header="First Tab Item"
                 local:TestWindow.IsFirstTab="true">
        </TabItem>
    

    Then, you should define a trigger for it:

    <Trigger Property="IsSelected" Value="True">
        <Setter TargetName="Border" 
                Property="Background" 
                Value="WhiteSmoke" />
    </Trigger>
    <Trigger Property="local:Window1.IsFirstTab" Value="True">
        <Setter TargetName="Border" 
                Property="Background" 
                Value="Red" />
    </Trigger>
    

    This must help.

    The same trick would work with last tab. Or you can have a number instead of bool as attached property.

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

Sidebar

Ask A Question

Stats

  • Questions 507k
  • Answers 507k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you were using SQL Server, the query you would… May 16, 2026 at 3:59 pm
  • Editorial Team
    Editorial Team added an answer LINQ on the collection will always be LINQ-to-objects, as they… May 16, 2026 at 3:59 pm
  • Editorial Team
    Editorial Team added an answer Yes, it's possible. What have you tried so far? Are… May 16, 2026 at 3:59 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a simple site to develop and would like to learn PHP as
I have an existing website that I need to develop a small portion of
Currently I have ReSharper installed to help me develop and edit code, and made
I have develop a framework where most of its path depend on __DIR__ .
I'm kinda new in the mobile world and wcf world. I have develop a
I don't have 64bit windows, and i have to develop app for 64bit windows.
I have the need to develop a custom HttpHandler in SharePoint. To start, I
I have updated to Xcode 3.2.3 to develop for the iPad and iPhone 4,
I must develop a simple web application to produce reports. I have a single
We have a .NET application on which has grown beyond what we can develop

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.