RadRibbonGroup fill space

2 posts, 0 answers
  1. Maurício
    Maurício avatar
    41 posts
    Member since:
    Jan 2011

    Posted 01 Sep 2014 Link to this post


    I would like to know how I could fill all empty space in a RadRibbonTab with a RadRibbonGroup.
  2. Martin
    Martin avatar
    1042 posts

    Posted 02 Sep 2014 Link to this post

    Hello Maurício,

    There is no out-of-the-box approach for expanding a ribbon group in all available space of its ribbon tab. However, you can achieve this with custom code. Basically you can create a custom groups panel that inherits the RibbonGroupsPanel and override its ArrangeOverride() method. 

    public class CustomPanel : RibbonGroupsPanel
        private const double Padding = 5d;
        protected override Size ArrangeOverride(Size finalSize)
            var size = base.ArrangeOverride(finalSize);
            var groups = this.Children.OfType<RadRibbonGroup>();
            double x = 0d;
            for (int i = 0; i < groups.Count(); i++)
                var group = groups.ElementAt(i);
                double width = group.DesiredSize.Width;
                if (i == groups.Count()-1)
                    var ribbon = this.ParentOfType<RadRibbonView>();
                    width = Math.Max(0, ribbon.ActualWidth - x - Padding);
                    group.Arrange(new Rect(x, 0, width, finalSize.Height));
                if (width > 0)
                    x += width + this.ItemSpacing;
            return finalSize;
    Then set it as an ItemsPanel of the RadRibbonTabs.

        <ItemsPanelTemplate x:Key="RadRibbonGroupPanelTemplate">
        <Style TargetType="telerik:RadRibbonTab">
            <Setter Property="ItemsPanel" Value="{StaticResource RadRibbonGroupPanelTemplate}" />

    I also attached a sample project demonstrating this approach. Please give it a try and let me know if it works for you.

    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
  3. DevCraft R3 2016 release webinar banner
Back to Top