Click here to Skip to main content
15,068,929 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I have a WPF application that is using the TabHead/TabItem elements. I want to create new elements at runtime, with the same content as the first element (usually a grid with more elements).

Basicaly I would want the function to look something like this:

public TabItem TabItemAdd(TabControl CHead, TabItem Example, String Header="New Tab" )
TabItem item = new TabItem();
item.Content = Example.Content;  // <-- This line doesn't work and is the problem
item.Header = Header;

return item;

Now I know that this doesn't work because the elements of the TabItem Example are allready childrean of CHead, but I'm not exactly sure how to unbind them or get it to work

Thanks in advance
Updated 23-Nov-11 12:00pm
SteveAdey 18-Jan-12 4:15am
Try using XamlReader to get the xaml out and then create that in the new TabItem.

1 solution

you can get a clone for tab item . then try to add. it will be work

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