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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:55:59+00:00 2026-05-24T06:55:59+00:00

Just started learning MVVM. I have a tabcontrol where I am adding multiple instances

  • 0

Just started learning MVVM. I have a tabcontrol where I am adding multiple instances of same views/pages

    Dim tb As New UXTabItem

    tb.Header = "Childrens"

    tb.Name = "tab" & itrt
    itrt = itrt + 1

    tb.Source = New Uri("/Views/childrens.xaml", UriKind.Relative)
UXTabControl1.Items.Add(tb)

Since each of the same view will handle different data but since the uri is same so all the tabs get populated with same view and changes reflect on each tabs. Which should not be the case. Should I be using a separate viewmodel for each of those? Any example would be much helpful.

  • 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-24T06:56:00+00:00Added an answer on May 24, 2026 at 6:56 am

    One of the primary goals/advantages of MVVM is that you don’t create WPF UI objects in code.

    You should be populating a collection of view model objects and binding the ItemsSource of the TabControl that you define in XAML to it. You should have a DataTemplate defined for the data type of those objects and put their XAML in there, instead of loading it at runtime.

    The TabControl is a little tricky, because it uses two templates: the ItemTemplate is used to define the look of the tab, and the ContentTemplate is used to define the look of the tab items’ content. It’s pretty common to see this:

    <TabControl ItemsSource="{Binding MyItems}">
       <TabControl.ItemTemplate>
          <DataTemplate>
             <TextBlock Text="{Binding Text}"/>
          </DataTemplate>
       </TabControl.ItemTemplate>
       <TabControl.ContentTemplate>
          <DataTemplate>
             <ContentPresenter Content="{Binding}"/>
          </DataTemplate>
       </TabControl.ContentTemplate>
    </TabControl>
    

    which populates the tab with a Text property on the view model, and the tab item’s content with whatever template in the resource dictionary matches the view model’s type.

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

Sidebar

Related Questions

I have just started learning MVVM and having a dilemna. If I have a
I have just started learning MVVM. I've made the application from scratch by following
I have just started learning Erlang and am trying out some Project Euler problems
I have just started writing my own JavaScript Framework (just for the learning experience),
Hello i have just started learning mvc2 and im having a problem with the
I have just started learning C#. Can anyone explain the technical differences between a
Possible Duplicate: MVVM: Tutorial from start to finish? i just started learning WPF. i
Just started learning Jquery - here's my problem: I have six divs on a
Hi Just started learning c for uni (usually use objective c) and have run
I just started learning Zend (& OO PHP for that matter), I have spent

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.