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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:50:04+00:00 2026-05-26T19:50:04+00:00

I have a custom tab control, which displays a frame inside the TabItem, and

  • 0

I have a custom tab control, which displays a frame inside the TabItem, and a custom header. Setting the binding in ItemContainerStyle to display the TabItem works, but I can not get the binding in the DataTemplate to set the header text to work correctly. Note that the TabControl is bound to an ObservableCollection of items, which contain two properties – TI, the frame to display in the TabItem, and DisplayName, the string to display in the header.

===============XAML================

<TabControl Height="Auto" Name="mainTabControl" Width="Auto" IsSynchronizedWithCurrentItem="True" Margin="4" >
  <TabControl.ItemTemplate>
    <DataTemplate>
      <DockPanel Width="Auto">
        <Button 
            Content="X"
            Cursor="Hand"
            DockPanel.Dock="Right"
            Focusable="False"
            FontFamily="Courier" 
            FontSize="9"
            FontWeight="Bold"  
            Margin="0,1,0,0"
            Padding="0"
            VerticalContentAlignment="Bottom"
            Width="16" Height="16"               
            >
          <!-- Command=""      //Command binding TBD later
            CommandParameter="" -->
        </Button>
        <ContentPresenter 
            Content ="{Binding DisplayName}"
            VerticalAlignment="Center" 
            Margin="0,0,7,0"
          />
      </DockPanel>
    </DataTemplate>
  </TabControl.ItemTemplate>

  <TabControl.Style>
    <Style TargetType="TabControl">
      <Style.Triggers>
        <DataTrigger Binding="{Binding Items.Count, RelativeSource={RelativeSource Self}}"
                        Value="0">
          <Setter Property="Visibility" Value="Hidden" />
        </DataTrigger>
      </Style.Triggers>
    </Style>
  </TabControl.Style>
  <TabControl.ItemContainerStyle  >
    <Style TargetType="TabItem">
      <Setter Property="Content" Value="{Binding TI}"/>
    </Style>
  </TabControl.ItemContainerStyle>
</TabControl>

============BOUND ITEM=============

  class TabItemContainer : Frame
  {
    public event DependencyPropertyChangedEventHandler PropertyChanged;

    private void NotifyPropertyChanged(String info)
    {
      if (PropertyChanged != null)
      {
        PropertyChanged(this, new DependencyPropertyChangedEventArgs());
      }
    }

    private string displayname;

    public string DisplayName
    {
      get { return displayname; }
      set
      {
        if (value != this.displayname)
        {
          displayname = value;
          NotifyPropertyChanged("DisplayName");
        }
      }
    }

    public Frame TI { get; set; }
  }

===========CODE BEHIND=============

ObservableCollection<TabItemContainer> Tablist;

public MainWindow()
{
  InitializeComponent();

  Tablist = new ObservableCollection<TabItemContainer>();

  TabItemContainer tic = new TabItemContainer();
  tic.DataContext = tic;
  tic.DisplayName = "Untitled";
  tic.TI = new Frame();
  tic.TI.Navigate(new Page1());
  Tablist.Add(tic);
  mainTabControl.ItemsSource = Tablist;
  mainTabControl.SelectedIndex = Tablist.Count - 1;
}
  • 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-26T19:50:05+00:00Added an answer on May 26, 2026 at 7:50 pm

    Add a Header binding to your TabItem Style

    <TabControl.ItemContainerStyle>
        <Style TargetType="TabItem">
            <Setter Property="Content" Value="{Binding TI}"/>
            <Setter Property="Header" Value="{Binding }" />
        </Style>
    </TabControl.ItemContainerStyle>
    

    The DataContext in your Header isn’t automatically getting set to your TabItemContainer (I thought it did…. must be mistaken)

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

Sidebar

Related Questions

In Silver light Tab control ,i have adding custom tab header (name along with
I have a jquery tab control in which I am building a custom control
Problem I have a custom tab control using Chrome-shaped tabs that binds to a
I have a custom text box control which raises a routed event when its
So I have an existing project with a custom tab control nested within panels
We have a form which displays media items in tab pages of a tab
In my iPhone app I have implemented a custom tab bar which functions perfectly,
I have a custom built menu system in which I would like to load
Basically, I have a form with a custom control on it (and nothing else).
I have a tab-based application for windows, which I am developing by myself. I

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.