This is a migrated thread and some comments may be shown as answers.

Set TabItem Style On Bound Tabs

4 Answers 144 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
heavywoody
Top achievements
Rank 1
heavywoody asked on 04 Mar 2013, 07:31 PM
I am trying to find an example of how to set a TabItem style if the Tab Control is bound so the tabitems are dynamically generated? I see examples when you explicitly set the style on the tabitem, but how do you do that on a bound tab control?

All I am trying to do is make it so the selected tab header is blue instead of the default color.

4 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 07 Mar 2013, 02:59 PM
Hello Christian,

the RadTabControl has an ItemContainerStyle property which you can use to apply a style to all dynamically generated RadTabItems. The ItemContainerStyle property expects a Style targeting RadTabItem and makes sure to apply this style to all generated RadTabItem containers.

Also, you can use an implicit style, as you mentioned in your post. The implicit style is a style that is applied on all controls matching the targeted type within the region where it is defined. This means that if you create an implicit style targeting telerik:RadTabItem type, then the style will be applied to all RadTabItems generated(statically or dynamically) within the region of the style.

This is why you can use both approaches (described above) to create a custom ControlTemplate for the RadTabItems and change their default selection background.

Please let us know if you encounter any issues with this task.

Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
heavywoody
Top achievements
Rank 1
answered on 07 Mar 2013, 06:16 PM
I apologize, but I can't seem to get this to work.  As I mentioned, I am simply trying to get the tab header area to turn blue with white lettering when it is selected.  When I tried the RadContainerStyle and then set the header, it just put a textbox inside the header and turned its background blue.  I want the whole tab header to turn blue.
0
Tina Stancheva
Telerik team
answered on 12 Mar 2013, 03:27 PM
Hello Christian,

In order to implement your scenario you will have to edit the default ControlTemplate of the RadTabItems. As the visual states of the RadTabItem include selection states that you need to override in order to get a blue background with white foreground during selection.

I attached a sample solution demonstrating how to edit the Office_Black RadTabItem.ControlTemplate to implement your requirements. Please note that I used an implicit style targeting RadTabItems in order to make sure that the custom ControlTemplate/Style will be applied to the dynamically generated RadTabItems.

Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
heavywoody
Top achievements
Rank 1
answered on 12 Mar 2013, 06:00 PM
That did it!  Thank you very much for showing me the way!
Tags
TabControl
Asked by
heavywoody
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
heavywoody
Top achievements
Rank 1
Share this question
or