?

Log in

No account? Create an account
DevLynx

Ribbon Application Menu Bottom Pane

The Microsoft Office 2007 Ribbon has buttons located on a panel at the bottom of the application menu. In Office 2007 this panel contains two buttons: program options and exit the application. In fact, the application that I am using to compose this journal entry (Help & Manual 5) uses a ribbon control following this standard. The CAB DevExpress Extension Kit needs to support this standard. After finishing the Ribbon demo I decided to create a UIElementAdapter to fulfill this need.

Once again, there is a complication with the Developer Express controls which must be avoided in our quest for decoupling. DevExpress designed the container for the bottom pane to hold any control. DevExpress cannot anticipate how we will use this container. Therefore, DevExpress leaves the application menu active until the developer explicitly closes the menu. A major problem surfaces when a button launches a modal dialog prior to closing the application menu (see Q106244 and AB11484).

Our issue is that any module should be able to add a button to the bottom pane of the application menu. A dependency on the application menu or ribbon will be required since the developer may need to close the application menu. This violates our goal of decoupling.

One option is to add an additional event handler to the button when it is added to the UIElementAdapter with the call UIExtensionSites[extensionSite].Add(button). This allows the developer to use the standard CAB commands and assign a Click event via AddInvoker. This would allow us to call the event handler to close the application menu and call the commands Invoker event.  However, the code

    UIExtensionSites[extensionSite].Add(button);
    Commands[CommandNames.MyCommand].AddInvoker(button, "Click");

could just as easily be written as

    Commands[CommandNames.MyCommand].AddInvoker(button, "Click");
    UIExtensionSites[extensionSite].Add(button);

In the latter case, the command will be fired before our event handler and the application menu is not closed at the right time. Furthermore, I can find no documentation that the events are guaranteed to fire in any specific order. So this approach was abandoned.

Another option would be to have the developer fire an event from the command handler to close the application menu. But this means that the developer requires knowledge of where this specific command is located in the interface or call this event from all command handlers. This option hold no appeal.

So I decided to go back to the same method that is used for both the GalleryItem and the dynamic UI elements. The button Tag property is used to hold an event name. The UI element adapter handles the click event. When any button in the bottom pane is clicked the UI element adapter closes the application menu and then fires the event. Again, I think that this is a compromise between decoupling which hides details from the developer and how the DevExpress control functionality.

You will find the code for the RibbonAppMenuBottomPaneSimpleButtonUIAdapter in the latest source code change set on the CAB DevExpress Extension Kit web page.

The last Ribbon item I am planning to add to the CAB DevExpress Extension Kit is creating an ApplicationMenu Right Pane workspace. However, this is not a high priority so it may be a few months before this is complete. If there are any other things that the Ribbon is missing please let me know and I'll see about getting to them in the future.

dlx

Comments