I need to load the region based on the RegionName binded. Somehing like
<ContentControl cal:RegionManager.RegionName="{Binding CustomRegionName}"
Grid.Column="2"/>
All the regions are registered properly. If I change the value of CustomRegionName the region never changes. How can I do this?
Prism regions are essentially named placeholders within which views can be displayed. Any control in the application's UI can be a declared a region by simply adding a RegionName attached property to it, as shown here.
A region is a placeholder in the application UI into which modules are injected. You can mark a control as a region using any of the following approaches. Set the UIRegion. Region attached property. XAML.
The shell is usually the MainWindow or MainPage. Implement this method by returning an instance of your application's shell class. In a Prism application, you can create the shell object, or resolve it from the container, depending on your application's requirements.
Prism is a Microsoft framework which assists you to design and build rich, flexible, and easy-to-maintain complex applications specific to Windows Presentation Foundation (WPF) desktop applications, Silverlight Rich Internet Applications (RIAs), and Windows Phone applications.
This behaviour is because the region is already loaded into the visual tree. Could you alter your app slightly so that you maintain the region name but load multiple views into the region. This way you would be able to select which view is active in the region and dynamically change the display of the content control by using the IRegionViewManager and IRegion interfaces i.e
IRegion region = regionManager.Regions["RegionName"];
object view = container.Resolve<SomeView>();
object view2 = container.Resolve<SomeView2>();
region.Add(view);
region.Add(view2);
Then where you want to show a particular view somewhere else Inject the IRegionManager and then call
region.Activate(whichever view);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With