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

How to Hide the Tab Header Row

3 Answers 228 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Trevor Leybourne
Top achievements
Rank 2
Trevor Leybourne asked on 10 Jul 2010, 06:02 AM
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

3 Answers, 1 is accepted

Sort by
0
Trevor Leybourne
Top achievements
Rank 2
answered on 13 Jul 2010, 12:05 PM
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.
0
Kiril Stanoev
Telerik team
answered on 15 Jul 2010, 12:31 PM
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
0
Gene
Top achievements
Rank 1
answered on 25 Jan 2012, 05:58 PM
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.
Tags
TabControl
Asked by
Trevor Leybourne
Top achievements
Rank 2
Answers by
Trevor Leybourne
Top achievements
Rank 2
Kiril Stanoev
Telerik team
Gene
Top achievements
Rank 1
Share this question
or