Using Prism Framework in Xamarin Forms
There are the frameworks. But there is one framework that is standing out from the others :
- FreshMvvM: Super lightweight and just includes the stuff that vanilla Xamarin.Forms leaves out
- ExRin: A larger framework for enterprise-scale apps
- MVVMCross: Very popular Framework
- MVVMLight: Popular framework
- ReactiveUI: Reactive programming is definitely something I should look into more.
and there’s Prism.
- Prism: Has an excellent navigation system. This is what I’m using in my apps.
Prism provides a method of building XAML applications for the WPF, UWP, and Xamarin.Forms. Each platform has a separate release that is built individually on its own timeline. Prism enables you to implement a collection of design patterns when developing XAML applications. These include MVVM, dependency injection, commands, EventAggregator, and more by using a shared code base in a PCL for each platform. Prism 6 is open source and can be downloaded from the GitHub repository at https://github.com/PrismLibrary/Prism.
Prism enhances capabilities and design patterns for composite application development. Some of the key concepts that are defined in Prism include:
Modules. Modules are packages that are used for specific functionality. Modules can also wrap application infrastructure or servers to be reused in multiple applications.
Module catalog. For composite applications, the modules are discovered and loaded at runtime. Prism uses a catalog to specify the modules that are to be loaded, and which order they must be loaded in.
Shell. The modules are loaded into the shell. This defines the layout and structure of the application but is not aware of the individual modules that are being used.
- Views. Views are UI controls for a feature of an application.
- You can use an MVVM pattern in conjunction with a view View models. View models are the classes that wrap the presentation logic and state. These define the properties, events, and commands to control the view.
- Models. As part of the MVVM pattern, modules wrap any data for validation and rules for consistency and integrity.
- Commands. Commands can be objects or methods in a view model. Prism uses the DelegateCommand and CompositeCommand classes.
- Regions. Regions updates an application’s UI without requiring any changes to the underlying logic. The ContentControl, ItemsControl, ListBox, and TabControl controls can be used as a region.
- Navigation. Prism uses two methods of navigation: state-based and view-switching. State-based navigation uses an existing view that is updated. View-switching navigation creates new views and replaces existing views.
- EventAggregator. Prism uses the EventAggregator components to enable components to publish events and other components to subscribe to events.
- Dependency injection container. Prism uses dependency injection to manage dependencies between components. This enables dependencies to be added at runtime with Unity, MEF, or other dependency injection container.
- Services. Services define non-UI related aspects of an application. This can include logging, data access, and exception management. Services can be registered with a dependency injection container and used by other components.
- Controllers. Controllers use presentation logic to display information, including the Prism view-switching navigation.
- Bootstrapper. Bootstrapper is another component that can be used by an application to initialize Prism components and services.
Lastly, here are 3 Prism videos that I know and watched before.
And that’s a wrap. See you on my next blog.