Sharing user defined controls with other modules

Nov 10, 2008 at 11:16 AM
Hi all,

First, i'd like to say that i'm new with the base concepts of Prism (DI, Containers, ..). That being said, I would like to know what is the best way, using Prism, to share user defined controls with other modules. I obviously do not want to statically link a dll to each and every module composing my application. I was thinking of a module that will hold all of my controls but don't know exactly how to use such a module !

Thank you for your answers.
Nov 10, 2008 at 6:40 PM



To share a user control between different modules without having hard references between them you can do the following:

1.       Create a common Interfaces project to put the interface of your User Control. This project will be referenced by all the modules that want to use the User Control.

2.       Create a module that implements the interface of your User Control. Then, register in the container a type mapping between the interface and the concrete class implementation of your User Control as follows:


container.RegisterType<IMyUserControl, MyUserControl>();


3.       Define a module dependency from the modules that use the User Control to the one that implements it and registers the type mapping. If Module A has the interface and Module B will implement the view, you could write the following in case you were using the Configuration Module Enumerator.



    <module assemblyFile="Modules/ModuleB.dll" moduleType="ModuleB.ModuleB" moduleName="ModuleB">


        <dependency moduleName="ModuleA"/>





4.       Get an instance of the User Control using the container through the its interface as follows.




The following articles give some more information about some of the topics mentioned above.


About type mapping:

·         Unity Application Block Methods


About module dependencies:

·         Using the Directory Lookup Module Enumerator

·         Using the Configuration Module Enumerator


Please let me know if this helps.


Damian Schenkelman

Nov 12, 2008 at 3:23 PM
Thank you for taking the time to anwser me.
I started implementing your solution. And so far so good...