I dont understand how to use Regions in Prism correctly. For example, I have an application: Structure of my app I only have one ShellView (window) and ShellViewModel as DataContext (but it is not important). My problem is OrderView (each OrderView is separate window), that splitted on few regions (for example: Region1, Region2, Region3). For each region I use UserControl by injecting through modules (IModule), but I don't understand how I should use bindings for that.
I have few variants:
For variant 1: I creating OrderView by special service (code example from service):
OrderView view = IoCHelper.Resolve<OrderView>();
OrderViewModel ovm = view.DataContext as OrderViewModel; //(or using special property for that: view.ViewModel)
ovm.Data1 = ...;
ovm.Data2 = ...;
view.Show();
I don't understand how I can send other view-models for regions
My problem is that I dont know how to correctly transfer data from OrderViewModel to regions (without strongly linking region's controls to this view-model (because that controls can be used in other part of application with other view-model))
(sorry for my sometimes incorrect english)
I don't think regions will work very well in this case.
You should provide your own registry where each module registers its order components, i.e. a factory that creates instances of it. Also, add a data template to use when showing the order component.
Then, when creating the order view model to show in a new order view (not the other way round!), look at the registry and create all the components and add them to the order view model. The order view will then fetch those components from its order view model and show them, applying the data templates their respective module registered for it.