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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:46:31+00:00 2026-05-23T02:46:31+00:00

In Silver light Tab control ,i have adding custom tab header (name along with

  • 0

In Silver light Tab control ,i have adding custom tab header (name along with close button) using xaml Working perfectly .

{xaml code}

<Grid Height="559" Name="grid1" Width="953">
<sdk:TabControl Height="391" HorizontalAlignment="Left" Margin="105,57,0,0" Name="tabControl1" VerticalAlignment="Top" Width="729">
    <sdk:TabItem  Name="tabItem1" IsTabStop="False">
        <sdk:TabItem.Header>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="New Tab" Margin="1,1,1,1" VerticalAlignment="Center" />
                <Button Content="X" />
            </StackPanel>
        </sdk:TabItem.Header>
        <Grid />
    </sdk:TabItem>
</sdk:TabControl>
<Button Content="+" Height="23" HorizontalAlignment="Left" Margin="74,57,0,0" Name="button1" VerticalAlignment="Top" Width="31" Click="button1_Click" />
<Button Content="-" Height="23" HorizontalAlignment="Left" Margin="12,492,0,0" Name="button2" VerticalAlignment="Top" Width="31" Click="button2_Click" Visibility="Collapsed" />

Same implementation tried with .cs but i Could add stack panel inside the new tab header

code for your reference

   StackPanel st = new StackPanel();
            st.Orientation = Orientation.Horizontal;
            TextBlock txtb = new TextBlock();
            txtb.Text = "test";
            txtb.Margin = new Thickness(1, 1, 1, 1);
            txtb.VerticalAlignment = VerticalAlignment.Center;
            st.Children.Add(txtb);
            Button btn = new Button();
            btn.Content = "X";           
            st.Children.Add(btn);         

             tabControl1.Items.Add(new TabItem
            {
                Header =st              

            });

Help me to solve this problem . i need Custom tab header With button control

  • 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-23T02:46:32+00:00Added an answer on May 23, 2026 at 2:46 am

    You should be setting tbItem.Header = st. tbItem.Content is used to define the content of the tab, not the tab header.

    Your code would look something like this

      StackPanel st = new StackPanel();
      st.Orientation = Orientation.Horizontal;
      TextBlock txtb = new TextBlock();
      txtb.Text = "New Tab";
      txtb.Margin = new Thickness(1, 1, 1, 1);
      txtb.VerticalAlignment = VerticalAlignment.Center;
      st.Children.Add(txtb);
      Button btn = new Button();
      btn.Content = "X";      
      st.Children.Add(btn);
    
      TabItem tbitem = new TabItem();
      // Set the header to the stack panel with the 
      // TextBlock and Button
      tbitem.Header = st;
    
      // This is where you define the content
      // of the tab page. Here I just added a Grid 
      // as an example.
      tbitem.Content = new Grid(); 
    
      tabControl1.Items.Add(tbitem);
    

    Edit: Here is a complete example

    XAML With TabControl – Notice that I hook the Loaded event, this is where I will add the dynamic TabItem.

    <UserControl x:Class="SilverlightApplication1.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
        mc:Ignorable="d"
        d:DesignHeight="300" d:DesignWidth="400" >  
      <Grid x:Name="LayoutRoot" Background="White">
        <Grid x:Name="Container">      
          <controls:TabControl Name="tabControl1" Loaded="TabControl_Loaded">
    
          </controls:TabControl>
        </Grid>
      </Grid>
    </UserControl>
    

    Here is the Code behind

    using System;
    using System.Windows;
    using System.Windows.Controls;
    
    namespace SilverlightApplication1
    {
      public partial class MainPage : UserControl
      {
        public MainPage()
        {
          InitializeComponent();
        }
    
        private void TabControl_Loaded(object sender, RoutedEventArgs e)
        {
          StackPanel st = new StackPanel();
          st.Orientation = Orientation.Horizontal;
          TextBlock txtb = new TextBlock();
          txtb.Text = "New Tab";
          txtb.Margin = new Thickness(1, 1, 1, 1);
          txtb.VerticalAlignment = VerticalAlignment.Center;
          st.Children.Add(txtb);
          Button btn = new Button();
          btn.Content = "X";      
          st.Children.Add(btn);
    
          TabItem tbitem = new TabItem();
          // Set the header to the stack panel with the 
          // TextBlock and Button
          tbitem.Header = st;
    
          // This is where you define the content
          // of the tab page. Here I just added a Grid 
          // as an example.
          tbitem.Content = new Grid(); 
    
          tabControl1.Items.Add(tbitem);
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have downloaded the silver light from this http://www.microsoft.com/silverlight// I need to use this
I have a silverlight user control which is bound to a Document object. the
I have a Button (or a hyperlinkbutton) in Silverlight. I want to open a
Silverlight v2.0 is getting closer and closer to RTM but I have yet to
In Silverlight, I have a Vertical ListBox that has a Horizontal ListBox for each
Since silverlight does not have any support for DataSets/DataTables, what would be the best
In Silverlight, when you want to create a control dynamically, you must add the
I have been learning Prism and Silverlight and am now trying to create a
Does anybody have a good way of finding ALL the controls within an object
I have a Silverlight 2 application that validates data OnTabSelectionChanged. Immediately I began wishing

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.