Search code examples
c#wpfxamlmef

Adding widgets(Visual Components) dynamically to WPF applications


What would be the best way to add widgets dynamically in WPF application. Let's say that I defined a contract to be used by any visual components that want to add themselves to my application using MEF. Now at start up my program will load the plug-ins and add the widgets that it finds in some directory say (..\VisualExtensions). How can I do that with WPF and XAML since it uses declarative style and how can I also control the order by which the components appear.


Solution

  • I think you'll find the answer to your question here: http://msdn.microsoft.com/en-us/library/gg406140.aspx. It may seem overwhelming at first, but it's a very valuable series of articles. Pay special attention to Section 4, you'll find a sub-section entitled Registering and Discovering Modules.