General Question about adding Views in the Region

Topics: Prism v2 - WPF 4
Jul 22, 2010 at 8:56 PM
Edited Jul 22, 2010 at 9:07 PM
I have Just the general question .... What will be the best practice to do in WPF -to add the modules at the begining or ON demand ... we know eventually we need it.. - adding all the view at the begining to the region without activating --- does it hinder application performance - in which case it is best to use controller ..... -- Thank you
Jul 22, 2010 at 9:19 PM

In the Prism docs we cover a number of possible approaches for both module initialization and for view registration in regions.  I'd skim through the UI Composition and Modularity docs under both the Technical Concepts and Development activities in the chm file as a starting point.

With module initialization, we have options to intialize on demand or at app startup to allow flexibility for difference scenarios.  For some applications, all the modules need to be loaded for the applicaiton to be useful, so everything should be initialized at startup. For other types of apps, or scenarios where memory footprint or startup time are critical, loading most modules on demand may make sense.  There is a spectrum of possible approaches, dependent on the application user's needs and constraints.

For registering views with regions, there are three options:

  • Register the view type with region during module initialization.  This way, when region appears and is activated, the view will be created and shown.
  • Register a view instance with region during initialization. This way, the region and view should appear immediately.
  • If you need any other timing for registering views with regions, you will need a controller to orchestrate the registration when requested.

Again, all of these options apply to different scenarios, and one is not necessarily better than another.  Choosing which approach to take will depend on how you want the app to behave.

In summary, there is no one best practice for all situations... it depends on the needs of the application you are building which approach or mix of approaches makes the most sense.

I hope this helps,
Michael Puleio

Jul 22, 2010 at 9:28 PM
Thank You.. helped me to clarify my doubt ..