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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:44:49+00:00 2026-05-26T04:44:49+00:00

It is MVVM project. I have a ListBox with TabControls inside of it’s items.

  • 0

It is MVVM project. I have a ListBox with TabControls inside of it’s items. TabItems are different for each TabControl and are binded from ViewModel:

                <TabControl ItemsSource="{Binding Tabs}"
                </TabControl >  

Tabs are:

    public ObservableCollection<TabItem> Tabs
    {   get { return tabs;  }
        set {
            tabs = value;
            value.CollectionChanged += delegate
            {
                OnPropertyChanged("Tabs");
            };

            OnPropertyChanged("Tabs"); } }

Tabs are filled by the following way only once:

                Tabs = new ObservableCollection<TabItem>();

                if (details.Image != null || !String.IsNullOrEmpty(details.Summary))
                    Tabs.Add(new TabItem() { Header = "General Info", Content = new GeneralInfo() { DataContext = ItemDetails } });  ........... 6 different types

This is a bit info about what I have. Then I dinamically change DataContext’s of this TabControls to simulate scrolling.

All info from ViewModel is binded into control, but there is a problem with TabControl. Headers are binded. but content doesnt. All headers are deselected and TabCntrol content area is empty.

I have tried to make TwoWayBinding on SelectedIndex and SelectedItem, but it doesnt help….
Seems SelectedIndex doesn’t do anything that can select TabItem.
And SelectedItem doesn’t work,becuase as I think it has new reference after each changing of data context. Because TabControl.ItemsSource re-binds and new TabItems created.

Maybe someone solved same problem and knows solution?

Thanks

  • 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-26T04:44:50+00:00Added an answer on May 26, 2026 at 4:44 am

    I have solved the my issue.
    The problem was that I used controls as DataContext:
    – List of TabItems
    – Controls inside TabItems content
    There was some processes, that I dont undrstand entire. But, idea is that while DataContext’s changing, one DataContext can be assigned to 2 different TabControls. Since UI Controls cant belong to 2 parents at the same moment, so, binding that should show that controls from DataContext in content doesnt work. And doesnt throw excpetion (cause it’s binding Smile | 🙂 )

    So, I remove al UI objects from DataContext, and add object models. And create UserControls that display are Views for these object models

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

Sidebar

Related Questions

I have created a C#/MVVM project which runs fine when I run it from
I have MVVM Project and I want to share one object( singleton ) from
Scenario : In a Silverlight 4 MVVM project, we have a ListBox control containing
I have several xaml pages in a WP7 MVVM project. I want to take
I am working on a WPF MVVM Project. Now i have a DataGrid in
I have been looking into MVVM design patterns with WPF for a project. I
I'm using mvvm for my new project. I have a message dispatcher to send
I'm playing with my first wpf project using the mvvm pattern. I have Microsoft
The application I'm currently writing is using MVVM with the ViewModel-first pattern. I have
I'm fairly new to MVVM, and I have recently started a project cleaning up

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.