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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:16:16+00:00 2026-05-31T04:16:16+00:00

I have a TabControl in my WPF application. I want my application to basically

  • 0

I have a TabControl in my WPF application. I want my application to basically support multiple "instances" within the single program. For example, think about web browsers, they allow you to have multiple instances of websites in different tabs, I want to achieve similar functionality where my application contains several instances of "sub applications".

The problem I currently face is that I have to copy-paste the same XAML to every tab, because each tab has exactly the same markup and UI, but different data. Another problem is that I need functionality to dynamically create those tabs.

Here’s a screenshot of my application at its current state. As you can see, there are 2 tabs on the top and the second has transparent background since it’s inactive.

enter image description here

So, how do I create a tab-able system where the UI of the tab remains the same for every tab and I only need to develop with one XAML UI and duplicate that for each tab?

Requirements:

  • Every tab has the same UI.
  • Every tab has different data for the UI elements.
  • As a developer I want to work on the tab’s XAML only once and right within Visual Studio.

Ideally I would love a plain simple sample project/code where there is one unstyled tab control and the application upon startup dynamically creates 2-n tabs which all have the same UI, but with different data.

  • 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-31T04:16:17+00:00Added an answer on May 31, 2026 at 4:16 am

    As noted in another answer there are probably lots of ways to do this, but here’s my simple way:

    Define a DataTemplate that defines the content of each your identical tabs. The controls in the data template will bind to the view model of the currently selected tab. I’ve put a single TextBlock in my example but you can easily extend this.

    using this Xaml:

    <Page.DataContext>
        <Samples:TabBindingViewModels />
    </Page.DataContext>
    
    <Grid>
        <Grid.Resources>
            <DataTemplate x:Key="ContentTemplate" 
                          DataType="{x:Type Samples:TabBindingViewModel}">
                <TextBlock Text="{Binding Content}"/>
            </DataTemplate>
        </Grid.Resources>
        <TabControl ContentTemplate="{StaticResource ContentTemplate}"  
                    DisplayMemberPath="Header" ItemsSource="{Binding Items}" />
    </Grid>
    

    and this view model code:

    public class TabBindingViewModels
    {
        public TabBindingViewModels()
        {
            Items = new ObservableCollection<TabBindingViewModel>
                        {
                            new TabBindingViewModel(1),
                            new TabBindingViewModel(2),
                            new TabBindingViewModel(3),
                        };
        }
    
        public IEnumerable<TabBindingViewModel> Items { get; private set; }
    }
    
    public class TabBindingViewModel
    {
        public TabBindingViewModel() : this(0)
        {
        }
    
        public TabBindingViewModel(int n)
        {
            Header = "I'm the header: " + n.ToString(CultureInfo.InvariantCulture);
            Content = "I'm the content: " + n.ToString(CultureInfo.InvariantCulture);
        }
    
        public string Header { get; set; }
        public string Content { get; set; }
    }
    

    we get:

    enter image description here

    I quite like this tutorial on styling the tab control. You can easily put more complex content into the tab headers as well as the content.

    You should examine the full template of the tab control to gain an insight into how it works. Use Blend or VS11 beta to extract the template.

    In order to dynamically add/delete tabs, now all you need to do is add/delete items to the ObservableCollection of view models.

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

Sidebar

Related Questions

I have a WPF application with multiple TabItems within a TabControl. In one of
I have a TabControl within a TabControl. I want the outer TabControl to show
I have created a TabControl in a WPF application I'm writing. I re-templated TabItem
I have a WPF TabControl, with some TabItems. I want margins on the left
My WPF TabControl contains multiple TabItems. I want to visually alert users that data
I have a TabControl in my WPF application that uses the default colors for
I have a WPF application that uses a TabControl. Each TabItem will contain a
I have a WPF TabControl that I want to position the tabs with a
I have a Custom TabControl in a WPF application (attention: the technology is not
I have a WPF TabControl with two TabItems. Each TabItem contains a ListBox with

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.