New Posts New Posts RSS Feed: Create View on demand
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Create View on demand

 Post Reply Post Reply
Author
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Topic: Create View on demand
    Posted: 09-May-2012 at 2:57pm
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)));
Back to Top
rbautistaole View Drop Down
Newbie
Newbie


Joined: 01-Apr-2011
Posts: 37
Post Options Post Options   Quote rbautistaole Quote  Post ReplyReply Direct Link To This Post Posted: 09-May-2012 at 1:41pm
Hi.
I´m creating an app using the TempHire demo as base.
In TempHire on the ShellViewModel the workspaces are collected and CREATED througout the MEF IOC. how you do build the same idea but not CREATING the WorkSpaces on app Start, but when the Toolbar to the View is pressed?
 
thanks in advanced.
Ramiro Bautista
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down