This project has moved and is read-only. For the latest updates, please go here.

Models and ModelContainers

Prism doesn't really touch on the Model aspect of development.  AppCan adds some framework and patterns around using Models and ModeContainers(i.e. documents). The default implementation support a single document interface.



The Modelmanager keeps track of registered ModelTemplates, and created ModelContainers (i.e documents/files).  It supports getting default templates, creating/opening new ModelContainers,Closing ModelContainers, Saving model containers.  There are events for when ModelContainers have actions performed on them.

 By using the application Open, Close, Save, SaveAs commands the AppCanApp will invoke the model manager with the appropriate operation. (The behaviour can be overridden in the application class if desired.)


Model templates create a relationship between file types, model types, required serializers, and startup contexts for the Shell.  When added to the ModelManager, this way if the app is opened with a file it will look up the appropriate modeltemplate by file extension and instatiate the appropriate shell/context and ModelType.  The shell context should have a class registered using the type interface IViewContainer.

 Example of creating a new template in the OnStartup method of the App:

 protected override void OnStartup(StartupEventArgs e)
           App.ModelManager.AddModelTemplate(new ModelTemplate(typeof(NoteModel), ".can", "NewFile{0}.can", new BinarySerializer(), true, typeof(Shell), "/HelloWorld;component/Shell.xaml", "HelloWorld.mainwindow"));


            Bootstrapper bootstrapper = new Bootstrapper(this);



Last edited Mar 17, 2013 at 7:58 PM by davesspacebar, version 3


No comments yet.