Windows Presentation Foundation (WPF) is a Microsoft platform used to build graphical applications for workstations running the Windows operating system. First introduced in 2006 in the .NET Framework 3.0, WPF offers many improvements over previous Windows Forms, including the ability to build more user-friendly and dynamic user interfaces. It also provides powerful data linking capabilities and supports multimedia such as images, audio and video.

The MVVM (Model-View-ViewModel) pattern is a widely used software architecture in application development with WPF. This is a model designed to clearly separate the user interface (UI) and business logic, making source code management easier and more effective.

WPF

As more and more WPF applications were built, application developers looked for ways to improve responsiveness and reusability, and support libraries were born. Prism and ReactiveProperty are two of them. The combination of Prism and ReactiveProperty in WPF creates a powerful model for building complex applications with responsive and flexible user interfaces. Let's explore them and these outstanding features.

1. Prism 

Prism is a powerful library for WPF, supporting the MVVM model and providing features such as dependency injection, navigation, and modularization. Prism helps create well-structured and easy-to-maintain applications.

  • Prism provides DI containers: Prism is built on top of Dependency Injection to help create maintainable and testable applications, reducing or eliminating dependency on static and circular references. Prism offers 3 types of lifecycles:

Transient: receives a new instance each time a service or type is requested

Singleton: receives the same instance each time it is requested

Scoped: get new instance in each different container scope but same instance in same specific container scope.

  • Region Manager is a core service in Prism that helps manage regions and interactions between them. It allows defining, searching and navigating areas within the application.
Region Manager

The RegionManager class is responsible for creating and maintaining a collection of regions for the host controls. The RegionManager uses a control-specific adapter that associates a new region with the host control. The above illustration shows the relationship between the region, control, and adapter set up by the RegionManager.

  • Prism provides support classes for MVVM implementation such as ViewModelLocationProvider and BindableBase. ViewModelLocationProvider provides an AutoWireViewModelChanged method that will be called when attaching the AutoWireViewModel property to the view, helping to associate the view model with its view automatically. BindableBase class has implemented INotifyPropertyChanged, allowing them to provide change notifications to any control in the view when a property value changes.
MVVM

2. ReactiveProperty

It’s a library based on Reactive Extensions (Rx) for .NET that helps manage data streams and events in a reactive way. It provides an easy way to create response properties, commands, and other operations without having to write a lot of boilerplate code.

ReactiveProperty
  • ReactiveProperty supports observables properties by providing ReactiveProperty and ReactiveCollection classes. This feature supports declaring and tracking changes of properties.
  • ReactiveProperty library also provides a Commanding feature through the ReactiveCommand class. We can use it to bind the command to UI control  and invoke a callback function when this control’s event is triggered.

 

Above is the basic information about Prism and ReactiveProperty libraries. I hope it will be  a new idea for your next project.

References:

https://docs.prismlibrary.com/

https://okazuki.jp/ReactiveProperty/