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 4094820
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:47:56+00:00 2026-05-20T19:47:56+00:00

I have a WPF TabControl, with some TabItems. I want margins on the left

  • 0

I have a WPF TabControl, with some TabItems. I want margins on the left and right of the TabItems group, if that makes sense.

I’m going to draw some ASCII art below to make the point. I want a fixed margin to the left of tab one, but I also want a fixed margin to the right of tab three.

|--------------------------------------------------|
|            |-----||-----||-----|                 |
| <-Margin-> |  1  ||  2  ||  3  | <-Margin->      |
|------------|     ||-----||-----|-----------------|
|                                                  |
|  How do I get margin or padding on both          |
|    sides of my tabs?                             |
|                                                  |
|                                                  |
|--------------------------------------------------|

The number of tabs is unlimited, so they will stack as more are added. It needs to work correctly for that.

Also, note, that I don’t want to make the whole tab control smaller. Just the tabitem tabs or headers or whatever they are.

I found that if I set the tabs to have a margin of something like “60,0,-60,0”, I get the desired effect to the left of the tabs, but that seems like a hack, and won’t work for the right hand side.

I am using WPF 4.0 in VS 2010.

Cheers!

  • 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-20T19:47:56+00:00Added an answer on May 20, 2026 at 7:47 pm

    Try using this style.

       <Style  TargetType="{x:Type TabControl}">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type TabControl}">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="Auto"/>
                                    <RowDefinition Height="*"/>
                                </Grid.RowDefinitions>
                                <TabPanel
                 Grid.Row="0"
                 Panel.ZIndex="1"
                 Margin="60,0,60,-1"
                 IsItemsHost="True"
                 Background="Transparent" />
                                <Border
                 Grid.Row="1"
                 BorderBrush="Black"
                 BorderThickness="1"
                 CornerRadius="0, 12, 12, 12" >
                                    <Border.Background>
                                        <LinearGradientBrush>
                                            <GradientStop Color="LightBlue" Offset="0" />
                                            <GradientStop Color="White" Offset="1" />
                                        </LinearGradientBrush>
                                    </Border.Background>
                                    <ContentPresenter ContentSource="SelectedContent" />
                                </Border>
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
    

    EDIT

    You can give the margin directly to the tabpanel inside the controltemplate of tabcontrol

    Check the link for more

    http://www.switchonthecode.com/tutorials/the-wpf-tab-control-inside-and-out

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

Sidebar

Related Questions

My WPF TabControl contains multiple TabItems. I want to visually alert users that data
I have a WPF TabControl with two TabItems. Each TabItem contains a ListBox with
I have a WPF TabControl that I have set the ItemTemplate as well as
I have a TabControl in WPF / MVVM that is bound to an ItemsSource
I have a complex WPF control that for some reasons (ie. performance) is not
I have a problem with the selected item in WPF-TabControl that could be reproduced
I have a WPF application with multiple TabItems within a TabControl. In one of
I have a WPF click-once application that makes use of an unmanaged dll. When
I have a WPF application in VS 2008 with some web service references. For
I have several wpf pages with update/delete/add buttons. I want to display to the

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.