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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:43:54+00:00 2026-05-11T16:43:54+00:00

Is there a way in XAML to cause the tab item headers to stretch

  • 0

Is there a way in XAML to cause the tab item headers to stretch across the width of the tab control?

For example, I have three tabs: red, blue and green. If I have a tab control with its width set to auto, the tab headers will only fill up part of the space above the tab content, but I want them to fill up all the space. For my three tab example, red should take up the first third of the control, blue should take up the center third, and green the final third.

I have an idea how to do this in a code behind which I am working on now, but I am interested in doing this the easiest way possible.

  • 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-11T16:43:54+00:00Added an answer on May 11, 2026 at 4:43 pm

    I took Jordan’s example and made some changes to it. This version should work for any number of tabs:

    namespace WpfApplication1.Converters
    {
        public class TabSizeConverter : IMultiValueConverter
        {
            public object Convert(object[] values, Type targetType, object parameter,
                System.Globalization.CultureInfo culture)
            {
                TabControl tabControl = values[0] as TabControl;
                double width = tabControl.ActualWidth / tabControl.Items.Count;
                //Subtract 1, otherwise we could overflow to two rows.
                return (width <= 1) ? 0 : (width - 1);
            }
    
            public object[] ConvertBack(object value, Type[] targetTypes, object parameter,
                System.Globalization.CultureInfo culture)
            {
                throw new NotSupportedException();
            }
        }
    }
    

    Same namespace in the xaml:

    xmlns:local="clr-namespace:WpfApplication1.Converters"
    

    And this will make all tabs use it:

    <Window.Resources>
        <local:TabSizeConverter x:Key="tabSizeConverter" />
        <Style TargetType="{x:Type TabItem}">
            <Setter Property="Width">
                <Setter.Value>
                    <MultiBinding Converter="{StaticResource tabSizeConverter}">
                        <Binding RelativeSource="{RelativeSource Mode=FindAncestor,
                AncestorType={x:Type TabControl}}" />
                        <Binding RelativeSource="{RelativeSource Mode=FindAncestor,
                AncestorType={x:Type TabControl}}" Path="ActualWidth" />
                    </MultiBinding>
                </Setter.Value>
            </Setter>
        </Style>
    </Window.Resources>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to create a conditional binding in XAML? Example: <Window x:Name=Me
In my XAML, I have: <Image Height=150 HorizontalAlignment=Left Margin=0,4,0,0 Name=imgLogo Stretch=Fill VerticalAlignment=Top Width=417 />
Is there a way in XAML to determine if the ListBox has data? I
Is there a way to get Xaml details from an assembly?
Is there a way to convert HTML into XAML? I noticed that you can
Is there a way to do 'using' in XAML i.e. declare a namespace and
Is there any way to make a DataTemplate reference itself just from XAML? In
Is there a way to take a chunk of XML/XAML and load it as
Is there way to copy a file into Plone with WebDAV and have Plone
Is there a simple way to disable UI virtualization on a ListBox control? I'm

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.