I'm just wondering what the point of regions are. I guess I don't understand the problem they solve.
For example, I see a lot of people using regions for a navigation region, but then why not just have an ItemsControl bound to an ObservableCollection instead of having a region and load in different navigation elements into that region?
A real-world example of it's use/benefits over the alternatives would rock!
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.
Prism helps to create flexible applications by allowing them to be more easily updated as new capabilities are developed and integrated. Prism also allows WPF applications to be developed using common services and components, allowing the application to be deployed and consumed in the most appropriate way.
Prism is a framework for building loosely coupled, maintainable, and testable XAML applications in WPF, and Xamarin Forms. Separate releases are available for each platform and those will be developed on independent timelines.
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.
Regions allow you to define a spot in your program that exists for a specific purpose. So for example, you might have a Menu Region, or a Footer Region. You can then separate out the Views/ViewModels for those specific regions into their own section of the program.
So instead of having an ApplicationViewModel
containing properties for the MenuViewModel
and FooterViewModel
, and having the View bind each section to those properties, you would have separate ViewModels for Menu and Footer, and your ApplicationViewModel would only deal with the content. It's a better way to separate some logical boundries in your application.
Personally I think Regions are horribly overused and abused. I almost never use them unless I have something like a Header or a Footer that is unrelated to the rest of my Application code. They're also mostly used in View-First development, and I prefer ViewModel-First.
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