Split Button problem

Split Button problem

Anonymous
Not applicable
2,494 Views
4 Replies
Message 1 of 5

Split Button problem

Anonymous
Not applicable

I am trying to make a split button exactly like in Revit. 

For Exemple Slab in "Structure"

 

2019-08-06_15h52_35.png

 

As you can see the label is different from the first choice.

When I am creating my own splitButton with this code (I create from a custom model)

var splitButtonData = new SplitButtonData(dropDownButton.Name, dropDownButton.Name);
var splitButton = ribbonPanel.AddItem(splitButtonData) as SplitButton;
if (splitButton != null)
	splitButton.IsSynchronizedWithCurrentItem = false;

foreach (var pushButtonContent in dropDownButton)
{
	var button = new PushButtonData(
		pushButtonContent.CommandType.Name,
		pushButtonContent.Text,
		pushButtonContent.CommandType.Assembly.Location,
		pushButtonContent.CommandType.FullName);

		if (pushButtonContent.LargeImage != null)		
			button.LargeImage = BitmapToImageSourceConverter.Convert(pushButtonContent.LargeImage);
											
		if (!string.IsNullOrEmpty(pushButtonContent.AvailabilityClassName))
			button.AvailabilityClassName = pushButtonContent.AvailabilityClassName;

	splitButton?.AddPushButton(button);
}

Basically, dropDownButton.Name is "Form Deck", but

 

I get this

 

2019-08-06_15h57_19.png

 

I don't want the top button and description to be linked to first item.

Also if possible I would like the top button to be independent and have it own command handler based on a algorithm to chose the best option base on the selection in Revit.

Thank you for helping me.

 

Charles

 

 

0 Likes
Accepted solutions (1)
2,495 Views
4 Replies
Replies (4)
Message 2 of 5

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @Anonymous ,

The Ribbon SplitButton is designed to show the text and image of the current button, as what says in SplitButtonData: " This text will be displayed on the button if drop-down is empty. If sub-items are added,  then the split button will display the current PushButton's text.". You can try PulldownButton instead if possible.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 5

Anonymous
Not applicable

PulldownButton is not what I need. I need a top button and a pull down menu under. How can Revit achieve this behavior? Do you guys have special control in your toolkit not accessible to other developers? 

0 Likes
Message 4 of 5

Anonymous
Not applicable
Accepted solution

I answered myself. If anyone is wondering how to do  a split button like in Revit, you must use Autodesk.Windows.RibbonSplitButton instead.

Then use

ShowText = true;
IsSplit = true;
Size = Autodesk.Windows.RibbonItemSize.Large;

 

The binding of the command is different, but you guys can handle this part.

 

Hope that help anyone,

 

Charles

Message 5 of 5

ekouassi
Collaborator
Collaborator

Hi,
Can you add the lines of code please?

Thanks!.

0 Likes