Set TabItem Style On Bound Tabs

5 posts, 0 answers
  1. heavywoody
    heavywoody avatar
    79 posts
    Member since:
    Oct 2009

    Posted 04 Mar 2013 Link to this post

    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.
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 07 Mar 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. heavywoody
    heavywoody avatar
    79 posts
    Member since:
    Oct 2009

    Posted 07 Mar 2013 Link to this post

    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.
  5. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 12 Mar 2013 Link to this post

    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.

  6. heavywoody
    heavywoody avatar
    79 posts
    Member since:
    Oct 2009

    Posted 12 Mar 2013 Link to this post

    That did it!  Thank you very much for showing me the way!
Back to Top
UI for WPF is Visual Studio 2017 Ready