Initiating a module from different module

Topics: Prism v2 - Silverlight 4, Prism v4 - Silverlight 4
Dec 10, 2010 at 2:45 PM

Hi All,

 

I am creating an application where SHell will going to contain 5 Regions.

1. RibbonRegion or NavigationRegion => That will hold a module with buttons (one of them will be login button)

2. MainRegion=> this region will hold a module that when one of the button from navgation module is clicked

3. Right and Left Region and Bottom Regions for other static content.

 

So, the demo usecase will be that when user clicks on one of the buttons in the module which is in Ribbon region then it should load a module in main region. when the user clicks on the login button in ribbon region after successful login the navigation/ribbon region should change its view to new view that will contain some new buttons and when one of the buttons is clicked in this new module it should also load a module in the main region.

 

One choice would be using navigation application but working with prism and modularity will that work? still this is an open question for me but i tried to work with that but was unable to achive my goal.

 

YOur help and ideas will highly be appreciated

 

Thanks.


sirfmemon.

Dec 10, 2010 at 7:29 PM

Hi sirfmemon, 

Please take into account that you load Views not Modules in Regions. You can read more about in Chapter 8: Navigation.

To fulfill the view-composition scenario of your application you can find the concepts in Chapter 7: Composing the User Interface useful.

Here you might find useful these sections:

  • Regions
  • View Composition
  • Displaying Views in a Region Programmatically

As for navigation, if you are referring to Silverlight Navigation, this is supported in Prism. However, Prism provides you with Region Navigation, which is specifically designed for this kind of scenario.

You can get more information about this in the Navigation chapter of the Prism MSDN documentation.

I hope you find this information useful.

Thanks,

Miguel Bronzovic
http://blogs.southworks.net/mbronzovic

 

Dec 10, 2010 at 7:37 PM
Hi Miguel,

Thanks for your reply, but still the question comes that if in my view of ModuleA in Navigation region there is a button LoadModuleCView. On clicking this button can i load ModuleB View in MainRegion? if yes then please refer me how? and further these modules can be loaded seperately on Demand?

Thanks

Waiting for your reply.

sirfmemon


From: [email removed]
To: [email removed]
Date: Fri, 10 Dec 2010 12:29:39 -0800
Subject: Re: Initiating a module from different module [CompositeWPF:237886]

From: mbronzovic
Hi sirfmemon,
Please take into account that you load Views not Modules in Regions. You can read more about in Chapter 8: Navigation.
To fulfill the view-composition scenario of your application you can find the concepts in Chapter 7: Composing the User Interface useful.
Here you might find useful these sections:
  • Regions
  • View Composition
  • Displaying Views in a Region Programmatically
As for navigation, if you are referring to Silverlight Navigation, this is supported in Prism. However, Prism provides you with Region Navigation, which is specifically designed for this kind of scenario.
You can get more information about this in the Navigation chapter of the Prism MSDN documentation.
I hope you find this information useful.
Thanks,
Miguel Bronzovic
http://blogs.southworks.net/mbronzovic

Read the full discussion online.
To add a post to this discussion, reply to this email (CompositeWPF@discussions.codeplex.com)
To start a new discussion for this project, email CompositeWPF@discussions.codeplex.com
You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.
Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com
Developer
Dec 10, 2010 at 7:42 PM
Edited Dec 10, 2010 at 7:45 PM

Hi sirfmemon,

You can find samples on how to achieve this scenario in the Navigation Quickstart, as well as the Navigation Lab inside the Prism Training Kit.

On a separate note, you can load modules (which are functional units that contain not only visual components but also services and business logic) on demand. You can read about it in the "Loading Modules on Demand" section of this chapter from the Prism documentation. There are also Modularity QuickStarts which have samples that you might find useful to achieve this.

I hope you find this helpful.

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi

Dec 11, 2010 at 7:54 PM

Hi Guys,

First of all thanks for your very informative reply and finally with your suggestions uptil now i found what i want :-) hats off to you ppl.

Furthermore, i have one more use case as well for example. when user clicks on the "Login Button" in LoginView of the LoginModule on that event of that click i would like to change add views to navigation regions containing buttons and each button belongs to new module and has its on view on clicking it. In simple words when i click on login button from the login view can i add views from another module into the navigation region? though LoginVIew belongs to seperate module and the other views i wanted to load on the login button click event belongs to another module.

 

waiting for your prompt reply.

 

Thanks

 

sirfmemon

Developer
Dec 13, 2010 at 2:18 PM

Hi sirfmemon,

The scenario you're describing is posible. You could use the Event Aggregator to publish an event when you click the Login Button, and then make your modules subscribe to that event, so that when the event is published they add their views (containing your buttons) to the pertinent navigation regions.

You might find the following thread useful, as they deal with a similar scenario:

Login / Logout View Switching

Take into account that:

  • Even though the user in that thread is using Unity as the Dependency Injection container, the scenario could also be achieved with MEF with only minor changes.
  • The modules that contain the views are responsible for adding them to the regions. By publishing an event from your button, you're only communicating those modules that they have to add their views.

You can read more about this in the following articles from the Prism MSDN documentation:

I hope you find this helpful.

Guido Leandro Maliandi
http://blogs.southworks.net/gmaliandi