简体   繁体   中英

Re-initializing application in WPF / PRISM

We are building a WPF application using PRISM and MEF. In the application, the user will start out by browsing to a 'project file' which contains a large amount of meta data.

Based on the project meta data, a set of views and their dependent viewmodels will be created and the user can view / create / manipulate the project data.

The user can then go to open another project file, which should at that point completely re-initialize the application as if the user had restarted the application and this was the first project file being opened. The reason for this is that different project files could result in very different views being created.

How can this be done in WPF / PRISM / MEF? If it was a regular WinForms application we could deconstruct / tear down the base 'application form' if you will and start over by instantiating a new one, using the project meta data as the context.

Is there a way to do something similar in WPF/ PRISM / MEF? The behavior between different types of projects and the initialization required is too complex for the 'oh, just swap out the model and have the viewmodels fire property change events for the views to refresh themselves' approach.

How about you instantiate a new Bootstrapper over the current one and re-run it, in your Application OnStartUp ? I tested it and it seems to work, but would that be enough in your case ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM