Problem with WorkItemExtension

Topics: CAB & Smart Client Software Factory
Mar 17, 2006 at 12:10 PM
originally posted by: ChenJC

I ran into a funny problem. Here is the description of the WorkItem and the Extension thats related to the problem.
I have a WorkItem A, which adds a Form AF. Form AF contains a Toolstrip and a workspace.
There is a WorkItemExtension for A thats called AE and all it does is to add a Form EF to the workspace. Form EF contains a grid that would populate data. In Toolstrip, I register a button called ViewData and all it does is to create ViewDataWorkItem which open another Form VD to display the data.
ViewDataWorkItem can also be invoked by double clicking on a particular row inside the datagrid in Form EF.
Problem I am running into now is that I want user to be able to bring the VD form to the front if it already exists beacuse user can open as many VD form as there are rows in the Grid.
Things work fine when a new VD form is being created, but when I want to bring a already existing VD form to the front by double-clicking on the row , or by clicking on the ViewData button in toolstrip, I would end up getting different behavior.
It seems that ViewData button would invoke "Deactivate" event in the ViewDataWorkItem and invoke Activated event in A, but when I double click on the row in the Grid, it would only fire the EventSubscription method I bound that event to.
ViewData commandhandler and the EventSubscription methods both invoke the same helper function.
I don't understand why ViewData button would invoke Deactivate event on ViewDataWorkItem and then Activate event in A but the double click event wouldn't.

The only difference is that the Grid lives inside a WorkItemExtension. I have tried firing from the grid through Command (the same one as the ViewData button binds to) and I get the same result as the event way.

Has anyone run into similar problem and if so can you please share your solution?