RibbonPanel.AddStackedItems and SplitButton

RibbonPanel.AddStackedItems and SplitButton

mphelt
Participant Participant
1,568 Views
5 Replies
Message 1 of 6

RibbonPanel.AddStackedItems and SplitButton

mphelt
Participant
Participant

Currently ribbon SplitButtons can not be created using RibbonPanel.AddStackedItems method.

Only PushButtons, PulldownButtons, ComboBoxes and TextBoxes can be added this way.

Would it be possible to remove this limitation?

0 Likes
1,569 Views
5 Replies
Replies (5)
Message 2 of 6

jeremytammik
Autodesk
Autodesk

Dear Mphelt,

 

Please take into consideration that the user interface customisation possibilities supported by the Revit API are intentionally rather limited, in order to enforce a certain consistency across the default built-in UI and additional functionality provided by add-ins.

 

Therefore, you need to provide an extremely compelling reason for anything to be added.

 

Please explain in detail exactly what you are trying to achieve and why it canot be achieved in any other manner.

 

Maybe the easiest way for you to move forward will be to implement your own modal dialog within your own external command, in which you can implement your own user interface making use of the full range of possibilities offered by the .NET API.

 

A slightly more complex and powerful approach would be to implement a modeless form and user interface, again making full use of all .NET functionality, and communicate with your Revit add-in via external events, as demonstrated by the Revit SDK 

ModelessForm_ExternalEvent sample.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 6

mphelt
Participant
Participant

Hi Jeremy,

What I wanted to achieve is a button similar to the selected one:

SplitButton.png

I've already overcome this using ribbon features from AdWindows.dll, but I was just curious whether tha lack of it in RevitAPIUI.dll is intentional or not.

Best regards,

Michał Helt

0 Likes
Message 4 of 6

jeremytammik
Autodesk
Autodesk

Dear Michael,

 

Conhratulations on implementing your own workaround based on AdWindows.dll functionality.

 

Please note that this is unsupported and you are using that at your own risk.

 

Would you like to share it with us, in case other people would like to incur that risk as well?

 

Thank you!

 

I will ask the development team for you whether or not this omission is intentional.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 6

mphelt
Participant
Participant
var buttonData0 = new PulldownButtonData("A", "A");
var buttonData1 = new PulldownButtonData("B", "B");
var buttonData2 = new PulldownButtonData("C", "C");

var stackedItems =
  ribbonPanel.AddStackedItems(
  buttonData0,
  buttonData1,
  buttonData2
  );

var button0 = (PulldownButton)stackedItems[0];

var splitButton = (Autodesk.Windows.RibbonSplitButton)UIFramework.RevitRibbonControl.RibbonControl.findRibbonItemById(
  string.Join(
    "%", 
    "CustomCtrl_",
    "CustomCtrl_",
    ribbonTabName,
    ribbonPanel.Name,
    button0.Name
    ));
splitButton.IsSplit = true;
splitButton.IsSynchronizedWithCurrentItem = true;

Dear Jeremy,

That's the cleanest solution that I have found.

Best regards,

Michał Helt

Message 6 of 6

jeremytammik
Autodesk
Autodesk

Dear Michał,

 

Thank you very much for sharing that!

 

It looks perfectly clean to me.

 

I added it to The Building Coder as wel to make it easier to find:

 

http://thebuildingcoder.typepad.com/blog/2015/12/adding-a-stacked-split-button-to-the-ribbon.html

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes