Click here to Skip to main content
15,665,319 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am binding below tab item collection to two tab controls in two different screen when i switch between the screens tab control does not show any tab items can any one help on this.

private ObservableCollection<TabItem> _leftContent = new ObservableCollection<TabItem>();

        public ObservableCollection<TabItem> LeftContent
            get { return _leftContent; }
                _leftContent = value;

1 solution

Well it's obvious! You are using the same instance of TabItem in two places!

TabItem is a Control, i.e. UI and not logic.

The idea of code separation between logic & UI (for example MVVM) can help you here:

For each TabItem:

1. Crate a View-Model containing his data.

2. Every TabControl (UI) instance, creates a new instance of TabItem (The View) but use the same View-Model instance.

I hope it helps :)
Share this answer
hari111r 3-May-14 5:06am    
Hi Thanks for the solution Can you please tell me how to create a tab item on bind a collection of header and content to a tab control .
Shai Vashdi 3-May-14 6:17am    

Just create a class (View-Model) that is the DataContext of the TabItem. Every time you need to create a TabItem give him the instance of the this View-Model class as the DataContext.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900