A basic understanding of MVVM pattern is recommended

The Basic - WorkspaceViewModel, WorkspaceView, ViewLocator and the ViewService


The ViewLocator is a singleton class that contains a instance of class Dictionary<ViewModel, Func<ViewModel, UserControl>. Because it stores a function pointer, it allows different views to be created base on the ViewModel instance (not just type). Two registration methods are available:
  1. Register(ViewModelType, ViewType): A type association. Each ViewModel Type will only have one View type. A default constructor is required for the View. Simple but covers the majority of the ViewLocator usage.
  2. Register(ViewModelType, Func<ViewModel, UserControl>): The full registration allows developers to specify the logic on the View creation based on the ViewModel instance.


The type Albatross.WPF.Common.WorkspaceViewModel is the abstract base class for all workspace view models within the Albatross Shell.
  • It requires a constructor that takes a messenger instance.
  • It contains a virtual LoadAsync method that will be invoked asynchronously as the last step of the workspace creation.


Albatross.WPF.Common.WorkspaceView class inherits the UserControl class. It is the base class for all Workspace Views within the Shell.
  • The RibbonTabItem property. The property should be initiated in the xaml file of the derived view. Once the shell created the view, it will add the ribbon tab item to the main ribbon control.

How to send a MsgTopic.ShowWorkspace request to the Shell?

  • Option 1: Create the WorkspaceViewModel object first and send it the shell as a parameter.
    • LocalMessenger.Send<WorkspaceViewModel>(new ContactViewModel(), MsgTopic.ShowWorkspace);
    • Shell will still invoke the LoadAsync method of the view model as the last step of creating a workspace.
    • If the shell found an existing workspace whose viewmodel is the reference equal of the view model in the request, the shell will skip the request and select the existing workspace instead.
  • Option 2: Create a WorkspaceViewModelConstruct object. The WorkspaceViewModelConstruct object tells the Shell how to construct the WorkspaceViewModel object.
    • LocalMessenger.Send<WorkspaceViewModelConstruct>(WorkspaceViewModelConstruct.Create<ContactCollectionViewModel>((args) => { return new ContactCollectionViewModel(args); }, workspaceID), MsgTopic.ShowWorkspace);
    • The shell will try to determine if there is an existing workspace with the same view model type and the workspaceID. If that is the case, It will skip the request and select the existing workspace instead.
    • The shell will always create a new workspace if the workspaceID specified in the construct is null.
  • Either options requires the initial ViewLocator registration.

How to create a module

  1. Create a new project using the WPF User Control Liberay template and reference the Albatross.WPF.Common.dll
  2. Create the LocalModuleInit class that inherit the Albatross.WPF.Common.IModuleInit interface.
  3. Two function to implement:
    1. InitModule is invoked once for the App. Use it for app wide initializations.
    2. InitializeShell is invoked once every time a new Shell Window is created. Use the method to create the backstage app menu and shell specific initializations.
    3. Add a new "module" section the Shell app config file section /albatross/shell/modules. The shell will read this section to load the modules. Here is the attributes of the module element:
      • Name (required): the name of the modules should be unique
      • AssemblyName (required): the full qualified assembly name of the module.
      • ModuleInitClass(required): the name of the class that implements IModuleInit interface.
      • Path (optional): Specify a location of the module assembly files if the module is remote. Otherwise include the module files in the same folder as the shell bin folder.
      • DefaultUpdateMethod (optional): Specify the default update method if the module is remote. The options are Overwrite, CopyIfNewer, Checksum, CopyIfNotExisting
      • Icon (optional): Specify the resource path of the icon in the module assembly. The size of the icon should be 48x48.
    4. If the module is remote, add the module name to the probing path of the shell config file.
      • Probing path is a comma delimited string
      • /runtime/assemblyBinding/probing@privatePath="ModuleName1;ModuleName2"

What is a Remote Module

  • If the binary for the module is not in the same location as the shell binary, the module is considered as remote. The Path attribute in the module config section should be specified.
  • The shell will attempt to copy the remote module locally using the default update method specified. The module files will be copied to a sub folder with the same name as the module name. That's why the probing path is needed.
  • The remote module deployment happens every time the shell starts.

Last edited Jul 21, 2014 at 2:06 PM by rushui, version 21