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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:51:44+00:00 2026-05-16T15:51:44+00:00

How do I create n-numbers of tabs with the data controls in wpf? Let’s

  • 0

How do I create n-numbers of tabs with the data controls in wpf?

Let’s say the main application has a button called “new customer” and “save data.” When “new customer” is pressed a new tab appears with two text boxes “Name” and “Customer Number” contained in the tab, and so on. Once the two fields are populated, pressing the “save Data” should store the information from the focused tab into a database.

The problem I have is that I have a static name for the “Name” and “Customer Number” text boxes as x:Name=”CustomerName” and x:Name=”CustomerNumber”. I found that you cannot duplicate these.

Can someone advice on how I can tackle this problem? Thank you in advance!

  • 1 1 Answer
  • 1 View
  • 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-16T15:51:45+00:00Added an answer on May 16, 2026 at 3:51 pm

    Using MVVM:

    Have a View and a ViewModel for a New Customer, with a save button on the view, which executes code to save a Customer to the database. This code should live in a Customer model or Customer Service.

    The NewCustomerView would not need to have names associated with its controls as you will be binding their Text properties to the properties on the ViewModel or an underlying model, unless you have to reference them for some other purpose than getting the data from each one.

    On your main form you would have the Tab Control, with its item source set to a ObservableCollection on the MainWindowViewModel. Pressing the New Customer button would populate a new entry in to this ObservableCollection.

    In the MainWindowView you would put a data template which maps the NewCustomerViewModel to the NewCustomerView, such as:

      <DataTemplate DataType="{x:Type vm:NewCustomerViewModel}">
        <AdornerDecorator>
           <views:NewCustomerView DataContext="{Binding}"/>
        </AdornerDecorator>
      </DataTemplate>
    

    This is basically saying when the content is a NewCustomerViewModel, render a NewCustomerView.

    You should go and read up on MVVM as this will solve your naming problem, as well a better architected application.

    See Josh Smiths article on MVVM, there is lots of other information out there to read too.

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

Sidebar

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.