I use this extension:
public static void AddButtonToDropDown(this RibbonMenuButton menuButton, string buttonId, string buttonText, string description, string iconName, string command)
{
RibbonMenuItem button = new RibbonMenuItem();
button.Text = buttonText;
button.ShowText = true;
button.ShowImage = true;
button.LargeImage = LoadImage(iconName,, 32, 32);
button.Image = LoadImage(iconName, 16, 16);
button.Id = buttonId;
button.CommandParameter = command;
button.Description = description;
button.CommandHandler = new AdskCommandHandler();
menuButton.Items.Add(button);
}
With this CommandHandler:
public class AdskCommandHandler : System.Windows.Input.ICommand
{
public bool CanExecute(object parameter)
{
return true;
}
public event EventHandler CanExecuteChanged;
public void Execute(object parameter)
{
var ribbonItem = parameter as RibbonCommandItem;
if (ribbonItem != null)
{
Autodesk.AutoCAD.ApplicationServices.Document doc = AcAp.DocumentManager.MdiActiveDocument;
//Make sure the command text either ends with ";", or a " "
string cmdText = ((string)ribbonItem.CommandParameter).Trim();
if (!cmdText.EndsWith(";")) cmdText = cmdText + " ";
doc.SendStringToExecute(cmdText, true, false, true);
}
}
}