How to force all content tabs to have the same height

4 posts, 0 answers
  1. Geoffrey
    Geoffrey avatar
    48 posts
    Member since:
    Mar 2013

    Posted 21 Oct 2015 Link to this post

    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

  2. Dinko
    Admin
    Dinko avatar
    201 posts

    Posted 26 Oct 2015 Link to this post

    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
  3. UI for WPF is Visual Studio 2017 Ready
  4. Dinko
    Admin
    Dinko avatar
    201 posts

    Posted 26 Oct 2015 Link to this post

    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
  5. Geoffrey
    Geoffrey avatar
    48 posts
    Member since:
    Mar 2013

    Posted 26 Oct 2015 in reply to Dinko Link to this post

    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
Back to Top