How to call SmartPart from another module?

Jun 10, 2010 at 1:59 PM
Let's say I have create 2 library each has its smartparts. Would it be possible to from one library to show a smart part from the library?
Coordinator
Jun 10, 2010 at 2:04 PM

Sure.  A SmartPart is simply a UserControl, so you can load them up from any assembly.  The easy way is to add a reference, though even that isn't specifically required because you could add the extra library as a Module, have it load the smartpart and return it in some sort of a call that returns a known interface (as opposed to an instance type).

This is a pretty common technique for things like plug-ins.

Jun 10, 2010 at 5:23 PM
Thanks, I really don't want the modules to know of each other so I can use them as plugins and reuse them for some other mobile products. So in the override Load of the modules, I'd have to add the smartpart in the RootWorkItem.SmartParts?
Coordinator
Jun 10, 2010 at 6:09 PM

Sure, you could do it that way.  You could also use event aggregation to load up, or the modules could know about some interface that the consumer knows about and return objects that way.  There are plenty of ways you could do it - none are any more "correct" than the other.