views:

36

answers:

1

Dear SO,

I'm having some issues with Silverlight 4/ MEF. I have a basic framework setup with a Silverlight Navigation app at the core.

Image link to the diagram for clarification

The main app (Desu) contains some pages and controls that export en import nicely. I dynamicly load controls from Desu.Controls(like an imageviewer which i identify with the IImageViewer interface) and some pages from Desu.Pages.

The first problem I had was with dynamicly loading pages and being able to navigate to these pages (eg. use dummyhttp://blagh/desutestpage.aspx#/Activation when Desu.Pages was loaded from the xap). I solved this by using a custom MetaAttribute and a custom contentloader.

Now for the question part: I want to load the ImageViewerControl from Desu.Controls in HomePage in Desu. I haven't loaded the Desu.Controls into the package though. When i try to load the control it gives me CompositionException because it can't satisfy the ImageViewControl import. I tried setting AllowRecomposition=true but that didn't help.

So is it possible to load a control without satisfying all imports and, if yes, how does one do this?

+1  A: 

So you want the import to initially not be satisfied, but you want it to be added later?

You were on the right track with setting AllowRecomposition=true, but you also need to set AllowDefault=true. Then the property will be null if the ImageViewerControl isn't available, and will be set when it becomes available.

Daniel Plaisted
Awesome :) thnx
Yost