Big Business App + Prism + Regions

Topics: Prism v4 - Silverlight 4
Oct 15, 2010 at 9:41 PM
Edited Oct 15, 2010 at 9:45 PM

Hy guys,

I'm starting to rewrite a big business application, and I am considering to use Prism with Silverlight.

I studied the prism, I saw some videos and got some doubts:

The basic of my app is that i have a main page (Shell), with a main region. In that region i'll load the Modules. For Exemple:

When i click in the Customer button, i ll load the CusomerModule, and show the CustomerView in the MainRegion

When i Click in the Contact button, i ll load the ContactModule, and show the ContactView in the MainRegion.

All modules will be loaded "OnDemand".

Here my doubts:

1 - I register the CustomerView in the MainRegion, but when i go to the ContactsView, the CostomerView is sitll "Active"?

2 - How can i reload the CustomerView? i dont need only to show that the CustomerView again, because the user can do lots of things in that view, and when he come back to that view, i need to reload that.

3 - In a big app with lots of modules and views, isnt that a problem? lots of views crteated and in memory?

4 - Is there a better solution for that kind of app?

thx.

Oct 17, 2010 at 6:07 PM

Hi, you can remove the views in the region first where you intend to insert a new view. This might help -

if (RegionManager.Regions["RegionName"] != null)
            {
                List<object> views = new List<object>(RegionManager.Regions["RegionName"].Views);

                foreach (object view in views)
                {
                    RegionManager.Regions["RegionName"].Remove(view);
                }
            }

 

Oct 18, 2010 at 12:56 PM

Ok, i now i know how to remove the views from my region, but i need more information about the oder questions plz.

3 - In a big app with lots of modules and views, isnt that a problem? lots of views crteated and in memory?

4 - Is there a better solution for that kind of app?

 

Oct 18, 2010 at 10:06 PM

Hi,

I think that you can find interesting the following post from the Blaine Wastell's Blog: Customers using Prism

Regarding to your specific questions:

3 - In a big app with lots of modules and views, isnt that a problem? lots of views crteated and in memory?

If you add/remove your views from your regions, you should not see to increase your memory more than expected.

4 - Is there a better solution for that kind of app?

If you have a lot views and a complex navigation in your application, you could take a look at the last drop (10) of Prism, since it includes a Navigation Quickstart that might help you.

Hope this helps.

Fernando Antivero
http://blogs.southworks.net/fantivero

 

 

 

Oct 19, 2010 at 12:43 PM

Thanks alot fantivero

I'll take a look at the last drop (90) of prism, to see how the navigation works.

 

 


Oct 19, 2010 at 7:49 PM

I took a look at the "Quick Start Navigation" from prism 4 dop 10, and in that sample, he still doesnt destroy or remove the view from the region.

If u navigate to another module, the first module are not destroyed.

 

Oct 19, 2010 at 8:19 PM

Hi,

If you active a view in a ContentControl exposed as a region, the current active view will be deactivated. Additionally, Prism has introduced a new RegionMemberLifetimeBehavior that removes views from a region when they become deactivated since drop 9.

Either the view or its view model can opt in to this by using the RegionMemberLifetimeAttribute or the IRegionMemberLifetime interface.

For more information, you could take a look at the RegionMemberLifetimeBehavior class the following CHM(s):

  • Prism4APIReference-Desktop.chm
  • Prism4APIReference-Silverlight.chm

You could see an implementation of this  in the Region Navigation Quickstart:

  • ComposeEmailViewModel.cs, see the code comments.

There is no problem about the creation of the views when using RequestNavigate, since when a particular view is not located, a new instance of the view will be created. This concept is named just in time view creation.

For more information about this you could take a look at the following documentation section in the Prism4.chm:

  • View-Switching Navigation Quickstart (new), see the introduction section and the Implementation Details section

Hope this helps.

Fernando Antivero
http://blogs.southworks.net/fantivero

 

Oct 19, 2010 at 8:49 PM

Thanks fantivero, found it.

also found that post too: http://blogs.msdn.com/b/kashiffl/archive/2010/10/05/integrating-prism-v4-region-navigation-with-silverlight-frame-navigation.aspx

 

Oct 19, 2010 at 8:58 PM
Edited Oct 19, 2010 at 9:07 PM

Hi,

I am glad that you found it. Additionally, in the Karl Shifflett's blog you can find the following blog post: Prism v4 Region Navigation Pipeline

I think that you can find interesting the section that he talks about the IRegionMemberLifeTime.

Hope this helps.

Fernando Antivero
http://blogs.southworks.net/fantivero