Search code examples
c#ribbonrevit-api

How to stack buttons (grid layout) in a Revit Ribbon Panel


I've created a custom panel that I've placed in the Revit Modify tab. Currently, the buttons are placed strictly horizontally. I would like to stack them in a grid format (rows and columns). Does any know the way to access the layout properties or any other means of accomplishing this?

enter image description here

Code:

var pSource = new Autodesk.Windows.RibbonPanelSource()
{
    Title = sPanel,
    KeyTip = "P",
    Id = "autosprink_shr",
    IsSlideOutPanelVisible = true,
    Description = null,
    DialogLauncher = null,
    UID = null,
    Tag = null,
    Name = null
};

var hPanel = new Autodesk.Windows.RibbonPanel()
{
    Id = sPanel,
    Source = pSource,
    IsVisible = true,
    IsEnabled = true, 
};

string sBtnText;

pIcon = Properties.Resources.AS_Revit_UI_SelectLike_icon.GetHbitmap();
sBtnText = "Select All Like";
var pPanelBtn = CreatePanelButton(pIcon, sBtnText, "id_asselectalllike", "", 32, 32, BUTTONSIZE.LARGE);
Autodesk.Windows.ComponentManager.UIElementActivated += SelectAllLikeBtn;
hPanel.Source.Items.Add(pPanelBtn);

Solution

  • Yes. When you call the command to add the RibbonItem to the panel, you should instead call RibbonPanel.AddStackedItems();. You can pass in either two or three, and it will stack them into one "column".