0

I am developing a very small application in WPF and I decided to use the Prism 6.0 framework after not being satisfied with Caliburn.Micro and MVVM Light Toolkit.

I want to be able to use regions in my application but I don't want to use Unity and dependency injection because it's overkill for this application.

If I want to have a Shell which is the main window with a region defined that will either show ViewA or ViewB in its one region how can I do this without using a Unity or a UnityBootstrapper? I am having trouble figuring this out since all the examples online and learning material use Unity or some other DI system.

EDIT: To clarify further: I'm mostly trying to avoid Unity/DI because it's forcing me to use Modules where this application is very small and I wouldn't benefit from Modules and it would only serve to make the project harder to understand for new eyes.

Kyle V.
  • 4,752
  • 9
  • 47
  • 81
  • Unity is overkill, but Prism isn't? Prism uses DI, so you can use Unity or roll your own. –  Nov 01 '16 at 19:54

1 Answers1

1

Prism relies on IoC in order to function. You must have something that resolves objects in a Prism application. This can be one of the built-in DI containers, or a custom implementation that uses simple Activator.CreateInstance.

Regardless of if you use a supported DI container or your own implementation, you are not required to use modules. If you don't need them, don't use them. Nothing in Prism forces you to use modules.

I would be interested to know what about Prism you feel is "overkill", as that is an overloaded term and usually those comments are not well articulated.

  • How do I set up the region without having a module? For example, in this [example code](https://github.com/PrismLibrary/Prism-Samples-Wpf/blob/master/HelloWorld/Modules/ModuleA/ModuleAModule.cs) the module constructor gets the region manager and the region is given the Initialize() function of the module. – Kyle V. Nov 02 '16 at 14:40
  • Just define a region. https://github.com/PrismLibrary/Prism-Samples-Wpf/blob/master/HelloWorld/HelloWorld/Views/MainWindow.xaml –  Nov 02 '16 at 14:43
  • Ask for the region manager in your ViewModels when you need it. –  Nov 02 '16 at 14:43
  • Add it as a ctor parameter –  Nov 02 '16 at 16:16