A common requirement for applications is change the layout of the Shell depending on certain conditions.The best way to handle this scenario in CAB is having a DeckWorkspace on the Shell. Then, there might be different layouts implemented in terms of smartparts that might be shown under different conditions. Let's create a simple example. Think about two layouts: the CRM layout and the Transactions Layout. The proposed solution could be extended to as many layouts as the application needs.
First thing is the Shell. Here we have our Primary Workspace of type DeckWorkspace.
Having a DeckWorkspace will allow showing/hiding different layouts efficiently. This snippet of code shows how:
Each layout is a single SmartPart(UserControl). These layouts will hold a ZoneWorkspace. This type of workspace is well suited for UIs where multiple sources of information must be shown. It is similar to a Sharepoint webpage. Working with this workspace is a little tricky. You have to add Panels and assign those panels a ZoneName. Let's suppose we have the following layout for the CRM module:
The following code illustrates how to show different views within the ZoneWorkspace for this module.
And also, the same code applies to show a smartpart within the nested TabWorkspace in the samelayout. CAB is intelligent enough to detect that the Layout smartpart contains instances of IWorkspace and add it to the WorkItem container so we can use it later.
Finally, the next figure illustrates the layout for the Transactions module.
Download the sample solution from here