switching smartparts in workspace

Topics: CAB & Smart Client Software Factory
Sep 9, 2006 at 4:32 AM
originally posted by: wanderer1

I am unable to figure out how to override OnActivate and OnDeactivate in this factory. The scenario is that I have the outlook bar workspace and I have multiple buttons on it. Each button displays a smart part in another workspace and displays some buttons on a toolbar. However, when I click on my second button on the outlook bar I can see in the code where its firing the smart part but the view is not appearing.

The first view is still in side and the buttons from the first view are still being displayed. I need the buttons from the first view to disappear when another view is selected. How do I do that? Also, how do I deactivate the first view so that the second view will be on top and displayed.

Hope I am making sense. Basically trying to mimic the outlook application in the way it works.

Thanks!!
Sep 9, 2006 at 8:12 AM
originally posted by: wanderer1

Ok, I figured it out. I used the BankBranchWorkbench sample to find my answer. This is the code snippet that I was looking for and it solved my problem.

Action(ActionNames.ShowPurchaseCDView)
public void ShowPurchaseCDViewAction(object caller, object target)
{
IPurchaseCDView purchaseCDView = null;
if (_workItem.SmartParts.Contains(PurchaseCDViewKey) == false)
{
purchaseCDView = _workItem.SmartParts.AddNew<PurchaseCDView>(PurchaseCDViewKey);
}
else
{
purchaseCDView = _workItem.SmartParts.Get<PurchaseCDView>(PurchaseCDViewKey);
}
_workItem.WorkspacesWorkspaceNames.OfficerWorkspace.Show(purchaseCDView);
}

So whenever you add a view assign a unique key to that view. Then check to see if the view with that unique key exists, if it does then get it from the smartpart collection and show it.

Hopefully I am on the right track, if anyone has other suggestions please share.

Thanks