Message 1 of 23
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All,
I wonder if anybody can help me.
I have a few commands that I have created, and they work great if called via the command line.
[CommandMethod("MyCommand", CommandFlags.UsePickSet | CommandFlags.Redraw | CommandFlags.Modal)]
public void MyCommandFunction()
{
// MY CODE IS HERE
}I have also created a new ribbon tab, with panel, and RibbonButton, and assigned a CommandHandler which calls a Action (callback function). However, I can't seem to get my button to trigger 'MyCommand'.
RibbonCommandHandler ActionHandler = new RibbonCommandHandler();
ActionHandler.CallBack = CallBackFunction;
myButton.Id = "MyButtonID";
myButton.CommandHandler = ActionHandler;
public class RibbonCommandHandler : System.Windows.Input.ICommand
{
public Action<String> CallBack;
public event EventHandler CanExecuteChanged;
public bool CanExecute(object parameter)
{
return true;
}
public void Execute(object parameter)
{
if (parameter is RibbonButton)
{
RibbonButton button = parameter as RibbonButton;
CallBack(button.Id);
}
}
}
public void CallBackFunction(String message)
{
Document doc = Application.DocumentManager.MdiActiveDocument;
switch (message)
{
case "MyButtonID":
// I AM STUCK HERE .....
break;
}
}
Apologies if I have failed to explain my problem very clearly. I am not sure if I am even going around the issue the right way. But any assistance to point me in the right direction would be greatly appreciated!
Thanks,
James
Solved! Go to Solution.