I Am new in WPF application i need to develop the application how the VS2010 solution Explorer Tree view is working when user click the particular file it open in the new tab in the same way i need to develope to my application.
What i am done is i have the menu item like
when user click the menu item dynamically add the tab item with menu name . my problem is when i select the first menu item its working fine . when i am trying to click the next menu item it show error like this
--> Element already has a logical parent. It must be detached from the old parent before it is attached to a new one.
how to fix this problem any one help me.
this is my code in code behind
TabControl item_tabs = new TabControl();
TabItem newtab1 = new TabItem();
private void Window_Loaded(object sender, RoutedEventArgs e)
item_tabs = (TabControl)this.FindName("itemtab1");
private void new_men_Click(object sender, RoutedEventArgs e)
// TabControl item_tabs = (TabControl)this.FindName("itemtab1");
int count = item_tabs.Items.Count;
if (count == 0)
string itemname = new_men.Name.ToString();
// newtab1.Content = itemname;
newtab1.Header = itemname;
View Complete Post