Hello,
I am working on an add-in where we would like to allow users to change the button's tab or panel positions as they want within a configurator window that we will be creating. I searched online I saw some article's saying it may not be possible but I wanted to give it a try in this post.
https://forums.autodesk.com/t5/revit-api-forum/change-ribbonitem-button-properties-at-runtime/m-p/82...
My question is if it is doable or not on runtime. Is there any type of button or approach that can achieve this on runtime?
Solved! Go to Solution.
Solved by ricaun. Go to Solution.
Solved by jeremy_tammik. Go to Solution.
I am not aware of any official Revit API support for this. I think that the panel and button orders are determined by their sequence of creation, but that is not officially stated anywhere, afaik, and would need testing. Once that is established, even if unsupported, you might be able to change their order by destroying the previous ones and recreating them afresh in a different order. That all sounds awfully fragile to me.
There is a way to change the order using AdWindows.dll.
In the Autodesk.Windows.RibbonPanel and Autodesk.Windows.RibbonTab is possible to change the position of the items using the method Move from ObservableCollection.
Here are some simple samples:
Autodesk.Windows.RibbonPanel awRibbonPanel = ribbonPanel.GetRibbonPanel();
awRibbonPanel.Source.Items.Move(0, 1);
Autodesk.Windows.RibbonTab awRibbonTab = ribbonPanel.GetRibbonTab();
awRibbonTab.Panels.Move(0, 1);
I'm using my library ricaun.Revit.UI that has the methods GetRibbonPanel and GetRibbonTab.
I never tried to change the order of the Items in the RibbonPanel, but change the order in the Panels order in the RibbonTab I always use to reorder by Title.
I hope this helps.
See ya!
Panels and Items is a ObservableCollection class, so there are some implementations to make it simpler than using the Move method.
I used this as a reference to implement some Extension for OrderBy and others: https://stackoverflow.com/questions/19112922/sort-observablecollectionstring-through-c-sharp
Can't find what you're looking for? Ask the community or share your knowledge.