Balancing UI Invocation and Lazy workItem loading

Topics: CAB & Smart Client Software Factory
Oct 18, 2005 at 4:55 AM
originally posted by: Kidd_Kane

I'm in the predicament where I want my modules to be able to provide menu, toolbar, and explorerbar items, and upon clicking on one of these I'd like a contact for eample to be created by my contact workitem. However it seesm the only way I can do this is if I have a contact workitem created before hand. This means if I have 50 different object types, I'd need to create 50 workitems to show fifty different view types. As you imagine a user may not work with every view and I'd love to not create the workitem until the user needs it, but how can I lazy load my workitem, and still allow it to provide a CommandHandler for UI events? Does anyone have a solution to this?
Oct 18, 2005 at 10:19 AM
originally posted by: jolu1977

Take a look at:

http://luifit.net/blogs/jluif/PermaLink.aspx?guid=2b17f027-c149-4cb9-a7f2-222ab7999bca

There is some content about lazy creation of workitems. Also look at the BankTeller which does lazy creation of workitems.

hope this helps.
Oct 19, 2005 at 3:06 AM
originally posted by: Kidd_Kane

I've seen this article and I understand how to lazy create workitems, but my real issue is is it possible to somehow couple this with CommandHandler/EventBroker.
i.e.

WorkItemA has the following CommandHandler:

CommandHandler("ShowViewA")
public void OnShowViewA(object sender, EventArgs args){
...
}

I've setup WorkItemA to be lazy loaded but it has not been created yet

I click the menu item to show ViewA.

As you would expect nothing happens.

Is there a way to cause the act of me clicking on the view to create the WorkItem which in turn would then be able to handle the command invocation? It would only have to create the WorkItem once. I know I could have another handler setup that handles the command, checks if the WorkItem exists and if it doesn't exists creates it and then re-invokes the command but I was hoping that there might be a more elegant solution.