Take a look at the very latest TempHire that ships with Cocktail v0.6. I've refactored the Shell to support lazy instantiation of workspaces. The Resource Management workspace is now created the first time you click on the button in the toolbar. The Resource Manager workspace is defined as a LazyWorkspace like so:
public class StaffingResourceWorkspace : LazyWorkspace<StaffingResourceManagementViewModel>
{
public StaffingResourceWorkspace()
: base("Resource Management", false, 10)
{
}
}
IWorkspace now has a Content property that returns the actual workspace content, which in case of LazyWorkspace gets lazy instantiated upon first access.
[InterfaceExport(typeof(IWorkspace))]
public interface IWorkspace : IHaveDisplayName
{
bool IsDefault { get; }
int Sequence { get; }
IScreen Content { get; }
}
LazyWorkspace just holds metadata about the workspace itself.
In the Shell, the NavigationService is then configured with a custom activator, which activates the content instead of the workspace itself.
_navigationService = new NavigationService<IWorkspace>(this)
.Configure(config => config.WithActivator(navigation => ActivateItem(navigation.Target.Content)));