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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:59:12+00:00 2026-06-08T08:59:12+00:00

I started using WPF (in C#) some weeks ago and now i need help

  • 0

I started using WPF (in C#) some weeks ago and now i need help for some advanced use of tabcontrol.

Fisrt of all, I’m using a MVVM (Model View ViewModel) pattern for designing my application, and I have a constraint that is to try to not add code in code behind file (that inititalise xaml files).

Now my issue is to create dynamically new tabItems in my MainWindow View (Window) that shows an instance of my Detail View (Page) when I click on a button (“New Tab” button for example).

I have found a lot off stuff about dynamic creation off tabitem on the web but often with modifications in code behind files. I though using binding but I don’t know how can I use binding to this kind of stuff.

  • 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-06-08T08:59:13+00:00Added an answer on June 8, 2026 at 8:59 am

    MVVM will help you out.

    Create a ViewModel for your MainWindow View. There you can have a collection
    of DetailViewModels. Just use an ObservableCollection of DetailViewModels here.

    In your View, bind the ItemsSource of the TabControl to that Collection.

    Your AddTab Button can have a Command Binding. That Command can be a ICommand
    derived class, that is published in the MainWindowViewModel. Pressing the button
    then ends up in the MainWindow ViewModel, adding another DetailViewModel and
    updating the View that way.

    Have a look to this excellent video tuturial on MVVM here: Jason Dollinger on MVVM

    He explains how that can be made, with examples for Main and Detail ViewModel
    and commands.

    The sourcecode that he develops in his video is available here: Sourcecode on Lab49

    Perhaps it even easier for you to create a ViewModel that is just used
    by the TabControl. Set the DataContext of the TabControl to that
    TabControlViewModel then. Publish that TabControlViewModel in your
    MainWindowViewModel as a public property, to accomplish that.

    Your code-behind will be empty, except some InitializeComponent perhaps.

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

Sidebar

Related Questions

I've just started learning WPF MVVM using Prism and Unity. Decoupling the view from
I recently started using WPF and the MVVM framework, one thing that I have
I've recently started using WPF for developing my applications. Now I've come to a
I have started to build a WPF application in MVVM architecture (using Prism infrastructure).
As I started using WPF at higher DPI resolutions, I got into troubles with
We are using the prism and WPF to build application. Recently we started using
I started using NetBeans today, and it was all going swimmingly, until I came
I started using emacs and slime to develop some little service. I have found
I started using bundler (which is to my eyes a pure disaster). Now I
I'm creating a basic database application in WPF, and I have started using 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.