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

RadRibbonGallery Automatic Resizing?

2 Answers 35 Views
RibbonView and RibbonWindow
This is a migrated thread and some comments may be shown as answers.
Melissa
Top achievements
Rank 2
Melissa asked on 05 Feb 2014, 01:31 PM
Is there a way to have a RadRibbonGallery automatically resize its width based on the content available when the window is resized? I currently have the ViewportWidth set to display three of the items it contains, but if there is more window space available I would like for it to display as many as possible and fill up the remaining whitespace in the ribbon. I have seen this functionality in MS Word with the Styles gallery.

2 Answers, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 10 Feb 2014, 01:00 PM
Hi Melissa,

Unfortunately, the described functionality is not supported out of the box, but it could be achieved by using some custom logic. I prepared a sample project to demonstrate the approach which I used to implement this behavior. Almost all of the logic is handled in the SizeChanged event handler of the MainWindow. Basically I am changing the values of the Width, ViewportWidth and the PopupViewportWidth properties of the RadRibbonGallery, based on the window width: 
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
    //First reset the RibbonGallery Width properties based on the group state and the empty space in the ribbon tab
   ...
    //Then calculate the size of the gallery
    var windowOffset = this.Width - this.PreviousWindowSize;
 
    var galleryNewWidth = this.RibbonGallery.Width + windowOffset;
    var viewportNewWidth = this.RibbonGallery.ViewportWidth + windowOffset;
    this.PreviousWindowSize = this.Width;
 
    this.RibbonGallery.Width = Math.Max(this.RibbonGallery.MinWidth, galleryNewWidth);
    this.RibbonGallery.ViewportWidth = Math.Max(this.RibbonGallery.MinWidth, viewportNewWidth);
    this.RibbonGallery.PopupViewportWidth = Math.Min(this.RibbonGallery.MaxWidth, viewportNewWidth);
}

Please give this approach a try and let me know if it helps.

Regards,
Martin
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

0
Melissa
Top achievements
Rank 2
answered on 10 Feb 2014, 02:01 PM
Thanks, this helps.
Tags
RibbonView and RibbonWindow
Asked by
Melissa
Top achievements
Rank 2
Answers by
Martin Ivanov
Telerik team
Melissa
Top achievements
Rank 2
Share this question
or