I have been tasked with creating a UI container in which different UI's will be automatically loaded from DLL's. These UI's or views, will adhere to a common interface. In the assembly will also be information about settings that is to be displayed as treeview. What would be the best practices for creating such a solution in c# with WPF? Prism seems like the way to go - do you agree?
Asked
Active
Viewed 306 times
0
-
Your question is primarily opinion based and so is off topic for Stack Overflow. As such, I have voted to close it. However, take a look at the [WPF MVVM navigate views](http://stackoverflow.com/questions/19654295/wpf-mvvm-navigate-views/19654812#19654812) question. – Sheridan Mar 27 '15 at 08:56
1 Answers
0
Advantage of prism is, that it's well known and if you follow the practices, you can refer to prism documentation. I would say, the advatages end here.
You can use IoC container like Unity, or MEF to load your modules and inject some IApplicationContext implementation to module. You module will then inject stuff to ApplicationContext. No need for prism here.
let's assume you module is identified by IModuleImplementation:
public interface IModule
{
void Initialize(IApplicationContext applicationContext);
}
In your application bootstrapp your modules:
public void Bootstrap()
{
var applicationContext = new ApplicationContext();
IModule[] modules = LoadModulesFromDirectoryAssemblies();
foreach (var module in modules)
{
module.Initialize(applicationContext);
}
}
and the modules will inject whatever needed:
public class Module1 : IModule
{
public void Initialize(IApplicationContext applicationContext)
{
//inject Module1 services, views, menuitems, command etc. to applicationContext.
}
}
You shell window will then get injected stuff in application context and reflect it in UI.

Liero
- 25,216
- 29
- 151
- 297