title: Load WPF UI into MVVM application from plug-in assembly
body: <p>I am working on an application that uses a plug-in architecture to expand it's functionality. What is the best way to load WPF UIs from a plug-in? </p>
  
  <p>I will have a listbox listing all of the available plug-ins. When a plug-in is selected, a WPF UI defined in the plug-in should be displayed in a <code>ContentControl</code>. The options I have thought of include:</p>
  
  <ul>
  <li>Require a <code>UserControl</code> to be created that implements a specific interface. I am thinking this would make it easy for plug-in creation. Implement an interface and you are good to go. My question with this method is how to dynamically load the <code>UserControl</code> into a <code>ContentControl</code>. Also, since I am using the MVVM design pattern it seems that a <code>DataTemplate</code> would be preferred over a <code>UserControl</code>.</li>
  <li>Allow a <code>DataTemplate</code> to be loaded from the plug-in. I believe this would require the plug-in to contain a XAML file named a certain way. My application would read the <code>DataTemplate</code> into my resource dictionary like shown <a href="https://stackoverflow.com/a/919613/918431" title="in this question.">in this question.</a>  I have seen quite a few questions similar to this, except they usually only need to load one additional, predefined assembly to get <code>DataTemplates</code> from. This problem would require any number of unknown assemblies to be searched for <code>DataTemplates</code>.</li>
  </ul>
  
  <p>If I choose the second option, I think I could select the <code>DataTemplate</code> similarly to how <a href="https://stackoverflow.com/a/3925239/918431">this answer describes.</a></p>
  
  <p>Which method do you think is better? Or do you have a better way to accomplish this?</p>