How to Hide the Tab Header Row

4 posts, 0 answers
  1. Trevor Leybourne
    Trevor Leybourne avatar
    5 posts
    Member since:
    Feb 2010

    Posted 10 Jul 2010 Link to this post

    I have a situation where if there is a single TAB in the TAB Control I do not want the Header Row section with the tabs to show, however if there are more than 1 then I do. The tabs are dynamically created at runtime.

    How can I hide the tab header?

    TabHeader.Visibility = tabControl.Items.Count > 1 ? Visibility.Visible : Visibilty.Collapsed;

    Trevor
  2. Trevor Leybourne
    Trevor Leybourne avatar
    5 posts
    Member since:
    Feb 2010

    Posted 13 Jul 2010 Link to this post

    Found that the Tab.Visibility does in fact do this and does not hide the whole tab just the tab header. Need to iteration through all tabs and set the Visibility as Collapsed.
  3. DevCraft banner
  4. Kiril Stanoev
    Admin
    Kiril Stanoev avatar
    1512 posts

    Posted 15 Jul 2010 Link to this post

    Hi Trevor,

    The fastest way is to collapse it using the VisualTreeHelper class. For example if you have a method that removes TabItems (ex. RemoveTabItem()) it might look like the following:

    private void RemoveTab(RadTabItem tabItemToRemove)
    {
        // Remove the tab item
        this.tabControl1.Items.Remove(tabItemToRemove);
         
        if(this.tabControl1.Items.Count == 1)
        {
            Dispatcher.BeginInvoke(() =>
            {
                var root = VisualTreeHelper.GetChild(this.tabControl1, 0) as FrameworkElement;
                var headerElement = root.FindName("HeaderDockedElement") as UIElement;
                headerElement.Visibility = System.Windows.Visibility.Collapsed;
            });
        }
    }

    Give it a try and let me know if it helps.

    Best wishes,
    Kiril Stanoev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Gene
    Gene avatar
    11 posts
    Member since:
    Jul 2011

    Posted 25 Jan 2012 Link to this post

    Thanks, it wasn't apparent that the visibility property on the tab only controlled the header. Much easier than retemplating the control or modifying through the visual tree. Although the VisualTreeHelper approach might be useful in some cases.
Back to Top