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

How to force all content tabs to have the same height

3 Answers 668 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Geoffrey
Top achievements
Rank 1
Geoffrey asked on 21 Oct 2015, 09:31 AM
Hello,

I'm using RadTabControl in my application. The RadTabControl is into a Grid (RowDefinition = GridLength.Auto).
I want that all tabs content have the same height (the height of the first Tab).

How to bind content height of the tabs to the content height of the first tab ?

Hope, my question is clear.

Best regards,
Geoffrey

3 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 26 Oct 2015, 09:28 AM
Hi,

We need more time to check your scenario. We will contact you as soon we have more information about the case.

Thank you for your patience.

Regards,
Dinko
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Dinko | Tech Support Engineer
Telerik team
answered on 26 Oct 2015, 12:45 PM
Hi Geoffrey,

The TabControl's height depends on the height of the selected TabItem. In order to achieve your requirement you can get the height of the first tab item's Content and assign it to the tab control's Height. You can subscribe for the Loaded event of the TabControl and get the first tab item, then call the Measure() method of the content and get the desired height. I have prepared a sample project where you can see how to implement the desired behavior.
private void MyTabControlName_Loaded(object sender, RoutedEventArgs e)
{
    var tabControl = sender as RadTabControl;
    var maxSize = 0d;
 
    var container = tabControl.ItemContainerGenerator.ContainerFromIndex(0) as RadTabItem;
    if (container != null)
    {
        var content = container.Content as FrameworkElement;
        content.Measure(new Size(Double.PositiveInfinity, Double.PositiveInfinity));
        maxSize = content.DesiredSize.Height;
        tabControl.Height = maxSize;
    }
}

If this is not the solution you are looking for, please don't hesitate to contact us again. 

Regards,
Dinko
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Geoffrey
Top achievements
Rank 1
answered on 26 Oct 2015, 01:39 PM
Hello,

Thanks for your reply,

To make it work, I change maxSize = content.DesiredSize.Height; to maxSize = content.DesiredSize.Height + tabitem.Height; because some pixels of my control were truncate.

Thanks again for your reply.

Geoffrey
Tags
TabControl
Asked by
Geoffrey
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Geoffrey
Top achievements
Rank 1
Share this question
or