Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
449
Can I put Ribbon in a View instead of Shell, using CAB
posted

I am using Ribbon with a CAB application. We want the Ribbon in a View(not in the shell). but it comes out like in the attached file. with 2 form heads. We want the Ribbon's application menu and not the shells. Is a way to do this? If I put the Ribbon in shell, it comes out fine. but we don't want all toolbar handling in the ShellForm.cs. That is too much code there.

Do u have an good example to look for this? All CAB & Ribbon examples shows how to register Ribbon as UIExtension, but how to handle the clicks?

Thanks,

Parents
No Data
Reply
  • 2077
    Offline posted

    In the demo I have sent you (see: the post) I have shown you how to respond to click events on the ribbon tool buttons from the module that inserted the tool.

    If you have a look at the ModuleController class in the NewToolbar.Module you can see how we hooked the ToolClick event on a ToolButton:

    WorkItem.Commands[CommandNames.RibbonFirstButtonClick].AddInvoker(button1, "ToolClick");

    The event handler, which in CAB world is called a CommandHandler, you can find in the same ModuleController class:

    [CommandHandler(CommandNames.RibbonFirstButtonClick)]

    public void OnRibbonFirstButtonClick(object sender, EventArgs eventArgs)

    {

        MessageBox.Show(string.Format("Raised command's name: {0}", CommandNames.RibbonFirstButtonClick));

    }

    Basicly what the code does: it hooks the ToolClick event on the ToolButton placed on the ribbon we want to handle (in our case button1) with the WorkItem.Commands[].AddInvoker() and we create a basic event handler that we decorate with the CommandHandler attribute. The command handler method can be placed in ModuleController or in a presenter, or in any other place in your module.
    This way you add the ToolClick event handler in the module it has to run, not in the Shell project.
    HTH,
    Emanuel

Children