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

importMany and dynamic loading xaps

Apr 5, 2011 at 9:56 PM

first let me say, I really like this framework you have come up with here.  I am using Jounce in a LOB application that I am just getting started on.   I am using a modified version of your navigationviewModel from the simple navigation quickstart, I created a class for navigationbuttons to hold the data instead of attempting to pull it from the exported views.  I did this because I wish to build the navigation dynamically, but I also need to make my application modular.  I have my main application, with the main screen and the navigation control, and I export a navigation button for each of the module views that I need.  

The problem that I have run into is a strange one.  I am using [ImportMany(Allowrecompition = true)]  If I export a navigation button in my main application,  then whenever my modules load and recomosition fires off, I get the exports from the main app again..  it reloads those navigation buttons once for itself, then again once for each module I load up.

Is there some reason you can think of why re-composing the navigationbutton collection gets these exports over and over?

thanks for your help.

Apr 5, 2011 at 10:06 PM

That is the basic behavior of MEF - in recomposition, it will rebuild the entire collection. A common practice is to use the Import[] collection to trigger the changes, but move it to another collection selecting the distinct entities to maintain the "pristine collection." Let me know if that helps or if you need to go into it further - you'll notice in Jounce itself there are areas in the view and region management for example that use the distinct modifier to avoid collisions from this distinct behavior.