Return to last active view

Topics: CAB & Smart Client Software Factory
Jun 11, 2007 at 8:08 PM
This is probably really obvious and I'm just missing something. Nonetheless, here's my issue. I'm using the SCSF Extension (outlook bar) and showing various views in the right workspace. When a user double clicks on a record, I go to a detail screen for that record. There are various datagrids on the detail screen, which, when double clicked, will open a detail screen for that. If I switch to a different module/workitem (from the outlook bar), how do I return to the active window in the original workitem? I've looked at WorkSpace.ActiveSmartPart, but that holds the currently active view.

ViewA->ViewB->ViewC then ViewX, now how to go back to ViewC?

Any help would be much appreciated.

Jun 12, 2007 at 3:14 AM
If you Hide the ActiveSmartPart on the rightworkspace you should see the previous one. That's why it is called DeckWorkspace

Jun 12, 2007 at 4:06 PM
Thanks for realizing it is a deckworkspace. I forgot to mention that. OK, so if I switch from Module A to Module B and hide the ActiveSmartPart, it would hide ViewC. Then, if I switch back to ModuleA, hiding the ActiveSmartPart again, it would then show ViewB, would it not? If you can't tell, I'm fairly new to CAB, not sure I'm doing things exactly right, and pretty lost on this issue. I'm handling the events to show the smartparts in the ModuleController. Should I use separate WorkItems for editing the details?
Jun 12, 2007 at 4:33 PM
DeckWorkspace is so named because it is like a deck of cards, ie a stack. Hiding the workspace on top will reveal whatever was underneath it on the stack. Make sure you aren't closing or hiding workspaces when you don't need to, just keep calling show on a new workspace while leaving the previous one open so it remains on the stack.

If you need more complicated scenarios then you can use a UI service to keep track of things.. check out the ToolStripSample that Chris Holmes posted on his blog a few weeks ago ( i think) for a simple example of a ui service to keep track of views.
Jun 12, 2007 at 5:08 PM
That's what I'm doing, which is why I ran into this problem. When a user clicks on an outlook bar, it displays a datagrid in the right workspace. So, without tracking the stack of open views, I don't know how to get back to the last active view for a given module. I'm reading the Active View post by Chris right now. I'm not sure that will alleviate this problem, though. That seems to be more related to having multiple copies of the same view open. I'll read on and see if I can see any light...
Jun 12, 2007 at 6:22 PM
oh so you want to get back to the last view for a given module, not the last overall view.. in that case yea the ui service should work, just instantiate a uiservice within the scope of each module to keep track of its active view.. you could also instantiate another similar service at the rootworkitem level to keep track of the last used module if you need that functionality.