Hi,
I have a tabControl. I will be adding tabitems to it dynamically.
My problem is when I create a new tab with content and datacontext, all the old tabs also referring the lastly created tab's datacontext.
Below are the steps.
1. I create a tab. Its working fine.
2. I have created another tab. Working fine.
3. When go back to first tab and if I do any changes in content, then I observed that its referring the 2nd tab's dataContext. This is the problem I have.
I am setting the dataContext of tabControl as List<TabItem> as below. And I will create a tabItem. And adding it to this list.
private List<TabItem> m_ViewTabs = new List<TabItem>();
this.tabControl .DataContext = m_ViewTabs; //List<TabItem>;
a_TabItem = new TabItem();
m_ViewTabs.Add(l_Tab);
View l_View = new View();
ViewModel l_ViewModel = new ViewModel();
l_View.DataContext = l_ViewModel;
a_TabItem.Content = l_View;
a_TabItem.DataContext = l_ViewModel;
this.tabControl .Items.Refresh();
Could anybody help me what is the problem and how can it be solved.
Regards,
Mohan.