What is the difference between register a region to adding a region in prism?

c#, mvvm, prism, regions, wpf

Solution

If you want a different views to be displayed in the same region, you need to use RequestNavigate or view injection which you have used in your first method

RegisterViewWithRegion will associate the Region with the view, so that every time the control where the region is hosted become part of the visual tree the view is automatically resolved and displayed.

See the msdn entry for more information

Problem

I want to create a region with dynamic views(multiple views in one region). The region content need to be changed by ComboBox selection event(the comobox items are view instances). I want that a change in the ComboBox will change the view in the region by the selected view item. My question what is the difference between : ``` MyView view= new MyView(); IRegion region = new Region(); region.Name="MyRegion"; regionManager.Regions.Add(region); region.Add(view); region.Activate(view); ``` To: ``` regionManager.RegisterViewWithRegion("MyRegion",type(MyView)); ``` ? What is the best way to use dynamic regions?

Original source