We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to set width and height for each RibbonGalleryItem in a RibbonGallery of WPF Ribbon control?

Platform: WPF |
Control: Ribbon |
Published Date: November 13, 2015 |
Last Revised Date: April 13, 2021

You can change the height and width of the RibbonGalleryItems by using ItemHeight and ItemWidth properties of the RibbonGallery in WPF Ribbon control. These properties are applied to all RibbonGalleryItems when it is set to RibbonGallery.

The same has been explained in the following code example.

XAML

<syncfusion:Ribbon>
   <syncfusion:RibbonTab Caption="Tab1">
      <syncfusion:RibbonBar Header="Bar1" x:Name="bar">
         <syncfusion:RibbonGallery   ItemWidth="200" ItemHeight="150" VisualMode="DropDown" SizeForm="Large" Label="Design">
            <syncfusion:RibbonGallery.GalleryFilters>
               <syncfusion:RibbonGalleryFilter Label="All"/>
               <syncfusion:RibbonGalleryFilter Label="Group 1"/>                     
            </syncfusion:RibbonGallery.GalleryFilters>
            <syncfusion:RibbonGallery.GalleryGroups>
               <syncfusion:RibbonGalleryGroup Label="Group 1" syncfusion:RibbonGallery.FilterIndexes="0, 1">
                  <syncfusion:RibbonGalleryItem>
                     <Image Source="Images/RedLarge.png" Width="40" Height="40" />
                  </syncfusion:RibbonGalleryItem>
                  <syncfusion:RibbonGalleryItem>
                     <Image Source="Images/OrangeLarge.png" Width="40" Height="40" />
                  </syncfusion:RibbonGalleryItem>
                  <syncfusion:RibbonGalleryItem >
                     <Image Source="Images/BlueLarge.png" Width="40" Height="40"/>
                  </syncfusion:RibbonGalleryItem>
                  <syncfusion:RibbonGalleryItem>
                     <Image Source="Images/GrayLarge.png" Width="40" Height="40" />
                  </syncfusion:RibbonGalleryItem>
                  <syncfusion:RibbonGalleryItem  >
                     <Image Source="Images/PinkLarge.png" Width="40" Height="40" />
                  </syncfusion:RibbonGalleryItem>
               </syncfusion:RibbonGalleryGroup>                        
            </syncfusion:RibbonGallery.GalleryGroups>
         </syncfusion:RibbonGallery>
      </syncfusion:RibbonBar>
   </syncfusion:RibbonTab>
</syncfusion:Ribbon>

 

 

C#

//Ribbon
Ribbon ribbon = new Ribbon();
 
//Ribbon Tab
RibbonTab ribbonTab = new RibbonTab() { Caption = "Tab1" };
 
//Ribbon Bar
RibbonBar ribbonBar = new RibbonBar() { Header = "Bar1" };
 
//Ribbon Gallery items
RibbonGalleryItem item1 = new RibbonGalleryItem() { Content = new Image() { Source = new BitmapImage(new Uri("/Images/RedLarge.png", UriKind.RelativeOrAbsolute)), Width = 40, Height = 40 } };
RibbonGalleryItem item2 = new RibbonGalleryItem() { Content = new Image() { Source = new BitmapImage(new Uri("/Images/OrangeLarge.png", UriKind.RelativeOrAbsolute)), Width = 40, Height = 40 } };
RibbonGalleryItem item3 = new RibbonGalleryItem() { Content = new Image() { Source = new BitmapImage(new Uri("/Images/BlueLarge.png", UriKind.RelativeOrAbsolute)), Width = 40, Height = 40 } };
RibbonGalleryItem item4 = new RibbonGalleryItem() { Content = new Image() { Source = new BitmapImage(new Uri("/Images/GrayLarge.png", UriKind.RelativeOrAbsolute)), Width = 40, Height = 40 } };
RibbonGalleryItem item5 = new RibbonGalleryItem() { Content = new Image() { Source = new BitmapImage(new Uri("/Images/PinkLarge.png", UriKind.RelativeOrAbsolute)), Width = 40, Height = 40 } };
 
//Ribbon Gallery Group
RibbonGalleryGroup group1 = new RibbonGalleryGroup() { Label = "Group1" };
Int32Collection filtervalue = new Int32Collection();
filtervalue.Add(0);
filtervalue.Add(1);
RibbonGallery.SetFilterIndexes(group1, filtervalue);
group1.Items.Add(item1);
group1.Items.Add(item2);
group1.Items.Add(item3);
group1.Items.Add(item4);
group1.Items.Add(item5);
 
RibbonGalleryFilter filter = new RibbonGalleryFilter() { Label = "All" };
RibbonGalleryFilter filter1 = new RibbonGalleryFilter() { Label = "Group1" };
 
//Ribbon Gallery
RibbonGallery gallery = new RibbonGallery() { ItemHeight = 150, ItemWidth = 200 };
gallery.VisualMode = RibbonGalleryVisualMode.DropDown;
gallery.SizeForm = SizeForm.Large;
gallery.Label = "Design";
gallery.GalleryFilters.Add(filter);
gallery.GalleryFilters.Add(filter1);
gallery.GalleryGroups.Add(group1);
 
ribbonBar.Items.Add(gallery);
ribbonTab.Items.Add(ribbonBar);
ribbon.Items.Add(ribbonTab);
grid.Children.Add(ribbon);

 

The following screenshot displays the change in the width and height of the RibbonGalleryItem

Set the height and width for RibbonGalleryItem in WPF Ribbon control

View sample in GitHub.

2X faster development

The ultimate WPF UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon