DevExpress Ribbon and Views

Topics: CAB & Smart Client Software Factory
Feb 19, 2007 at 7:40 PM
I'm using CAB with a flavour of the DevExpress library out there (one of the CAB wrappers someone wrote that I've trimmed down to just provide me with the Ribbon). The way the wrapper works is to add all the views at startup and create the ribbon groups (using a helper method). This is fine if you want to show all your views, however we don't and so views are created in AddViews but retrieved with the Get method on the WorkItem.Items collection and shown when a command handler fires.

The problem is that OnViewReady is only being called when AddNew is called, not Get so drop down lists and things in the views are not being refreshed. Now I'm wondering what do here. Do I create a Load method and expose it in my view so I can call it from the module controller? I could expose the presenter (which doesn't have a getter) and then just call view.Presenter.OnViewReady manually, but that seems slimey. Or should I load and fetch my views differently?

Here's what we do:
1. In ModuleController.cs:
public void AddViews()
{
//viewId is just Guid.NewGuid().ToString() so we can retrieve the view later
MyRibbonView view = WorkItem.Items.AddNew<MyRibbonView >(viewId);
RibbonControlHelper.LoadRibbonGroup(createSubJobView, WorkItem, UIExtensionSiteNames.MainRibbon);
}

2. In a command handler in the same file:
[CommandHandler(CommandNames.ShowView)]
public void ShowViewHandler(object sender, EventArgs e)
{
MyRibbonView view = WorkItem.Items.Get<MyRibbonView >(_viewId);
WorkItem.Workspaces[WorkspaceNames.LayoutWorkspace].Show(view);
}

So I'm not sure if this is best, but how else should I retreive the views? Or should I just call AddView everywhere?

Thanks.