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

I would like to bind a TabControl to User Controls in order to have each User Control in a TabItem.

Is this possible, knowing the TabControl is itself in a UserControl ?

Thanks
Posted
Updated 23-Apr-13 21:38pm
v2
Comments
Naz_Firdouse 24-Apr-13 3:38am    
Do you want to customize the tabitem?
Curtis Wheller 24-Apr-13 3:39am    
Yes, I've already removed the header of the TabItems
Naz_Firdouse 24-Apr-13 3:40am    
not sure what you are trying to achieve???
please check this ...
http://tech.pro/tutorial/730/the-wpf-tab-control-inside-and-out
Curtis Wheller 24-Apr-13 3:51am    
The aim is not really to design the appearance of the TabControl but to display in a TabControl, User Controls that other people develop.
Naz_Firdouse 24-Apr-13 4:00am    
so you want to display the usercontrols as tabitem.right?

1 solution

You can add the usercontrol as a tabItem itself like
HTML
<tabitem header="My TabItem1">
        <local:tabusercontrol1 xmlns:local="#unknown" />
</tabitem>
<tabitem header="My TabItem2">
        <local:tabusercontrol2 xmlns:local="#unknown" />
</tabitem>





or add multiple datatemplates to the tabcontrol...
Check this
http://stackoverflow.com/questions/9796174/load-usercontrol-in-tabitem[^]
 
Share this answer
 
Comments
Curtis Wheller 24-Apr-13 4:19am    
Indeed it's a good idea to add the usercontrol as tabitem. But how can I bind the different tab item to the tabcontrol ? Actually, it's another person who will create the list of usercontrol, and he uses my usercontrol, that contains the tabcontrol, as a library. So he can't modify the code of the tabcontrol.
Naz_Firdouse 24-Apr-13 5:26am    
In that case, you can add the tabitems dynamically to the tabcontrol...
TabItem item1 = new TabItem();
item1.Header = "Header1";
item1.Content = new MyUserControl();
tabcontrol.Items.Add(item1);
Curtis Wheller 24-Apr-13 5:43am    
You solved my problem, thanks a lot.
Naz_Firdouse 24-Apr-13 5:55am    
welcome

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