ps-projects - PS.MVVM 2.2.17
Essential MVVM services implementation
PM> Install-Package PS.MVVM -Version 2.2.17 -Source https://www.myget.org/F/ps-projects/api/v3/index.json
> nuget.exe install PS.MVVM -Version 2.2.17 -Source https://www.myget.org/F/ps-projects/api/v3/index.json
> dotnet add package PS.MVVM --version 2.2.17 --source https://www.myget.org/F/ps-projects/api/v3/index.json
source https://www.myget.org/F/ps-projects/api/v3/index.json
nuget PS.MVVM ~> 2.2.17
Copy to clipboard
> choco install PS.MVVM --version 2.2.17 --source https://www.myget.org/F/ps-projects/api/v2
Import-Module PowerShellGet
Register-PSRepository -Name "ps-projects" -SourceLocation "https://www.myget.org/F/ps-projects/api/v2"
Install-Module -Name "PS.MVVM" -RequiredVersion "2.2.17" -Repository "ps-projects"
Copy to clipboard
Build
Branch | Build status |
---|---|
Master | |
CI |
Packages
Name | Master | CI |
---|---|---|
PS.Primitives | ||
PS.WPF | ||
PS.MVVM | ||
PS.MVVM.WPF | ||
PS.IoC | ||
PS.IoC.Autofac | ||
PS.IoC.Microsoft.DependencyInjection | ||
PS.Windows.Interop |
Description
Lightweight and fast MVVM framework. This framework is designed to be generic, allowing for flexibility and adaptability. However, all future implementations will be specifically tailored for WPF (Windows Presentation Foundation).
Tutorial
Quick tutorial documentation can be found here:
How It Works
To ensure the correct resolution of any element, it's essential to register it. There are two primary items to be aware of when working with this system:
ViewModel Type Registration
The core key for registration is the ViewModel Type
. This allows you to register payload items for the ViewModel type you're testing, whether it's of the same type or inherited from it.
Elements for View Rendering
There are three main kinds of elements that play a role in view rendering:
DataTemplate for DataTemplateSelector:
DataTemplate: A DataTemplate is used in WPF to define the visual representation of data. It describes how data should be displayed, allowing developers to create a template that defines how data objects are rendered in UI elements like ListBox, ComboBox, and more.
Usage Example:
service.AssociateTemplate<ShellViewModel>(dataTemplateInstance);
DataTemplateSelector: This is a class in WPF that lets you choose a DataTemplate based on custom logic. It becomes particularly useful when you have multiple templates and you want to select one based on the properties of the data object.
Style for StyleSelector:
Style: Styles in WPF empower developers and designers to establish a consistent appearance across their applications. By defining the look and feel of UI elements, styles help in creating visually compelling and uniform effects across the application.
Usage Example:
service.AssociateStyle<ShellViewModel>(XamlResources.ShellWindowStyle);
StyleSelector: This class in WPF is used to apply styles based on custom logic. It determines how a style is selected for a row or an item, contingent on specific conditions.
ItemContainerTemplate for ItemContainerTemplateSelector:
ItemContainerTemplate: This template in WPF provides the blueprint for producing a container for an ItemsControl object. It essentially dictates how each item's container should be structured and styled within controls like ListBox or ComboBox.
Usage Example:
service.AssociateContainer<ShellViewModel>(itemContainerTemplateInstance);
ItemContainerTemplateSelector: This selector allows for the application of custom logic to pick an ItemContainerTemplate.
Generic Association
For a more streamlined approach, you can use a generic method to associate all the elements at once:
Usage Example:
service.Associate<ShellViewModel>(
template: dataTemplateInstance,
style: XamlResources.ShellWindowStyle,
container: itemContainerTemplateInstance);
Core Features
Built-in Selectors: The framework provides native selectors for Data, Style, and Container. These selectors facilitate efficient data binding, style management, and container operations in WPF contexts.
DI Framework Integration: PS.Framework integrates seamlessly with established Dependency Injection (DI) frameworks, specifically Autofac and Microsoft dependency injection. This integration allows for dependency resolution and inversion of control, leading to modular and testable code structures.
Scalability: PS.Framework is scalable, catering to both small-scale utilities and large enterprise applications. It ensures consistent performance and responsiveness across varying project sizes.
Toolset: The framework includes a suite of tools and services that enhance WPF development, reducing boilerplate and improving efficiency.
MVVM Services
In essence, the PS.MVVM project provides tools and services to facilitate the implementation of the MVVM pattern, making it easier for developers to separate their application's logic from its presentation.
BroadcastService
This service provides functionality to broadcast events to subscribers. It maintains a list of subscriptions and allows for broadcasting events to these subscribers. The service provides methods to subscribe and unsubscribe from events. It uses a synchronization context to ensure thread safety.
CommandService
This service deals with commands in the MVVM pattern. It maintains a registry of commands and provides methods to add commands, create views of commands, and find commands. The service can handle activation of commands and provides event handling capabilities.
ModelResolverService
This service provides functionality to resolve models. It maintains storage for observable model collections and observable model objects. The service provides methods to retrieve these observable collections and objects.
ViewResolverService
This service is responsible for resolving views. It maintains associations between consumer service types, view models, and regions. The service provides methods to associate views and find associated views.
MVVM WPF Adaptation
The PS.MVVM.WPF
project within the PS.Framework repository provides a set of components, services, and view models tailored for WPF applications, particularly for implementing the MVVM (Model-View-ViewModel) pattern. Here's a brief overview of the components:
Resolvers
In the MVVM architecture within WPF applications, resolvers play a pivotal role in dynamic UI determination. They ensure the appropriate visual elements are chosen based on the underlying data contexts.
BaseResolver:
- An abstract generic base class tailored for service interactions within XAML. It provides foundational mechanisms for consistent service retrieval across derived resolvers.
BaseViewResolver:
- A specialized XAML resolver for operations with the
IViewResolverService
. The service interacts with three distinct selectors:- StyleResolver: Works with WPF's
StyleSelector
, determining the right style for views. - ContainerResolver: Engages with
ItemContainerTemplateSelector
, ensuring the correct container for items in collection controls. - TemplateResolver: Operates with
DataTemplateSelector
, selecting the appropriate data template based on the data context.
- StyleResolver: Works with WPF's
- A specialized XAML resolver for operations with the
WindowService:
Service offers methods to display windows, either in a standard or modal fashion, based on the associated view model. This ensures a clear separation of concerns between the view and its underlying logic, adhering to the principles of the MVVM pattern.
-
.NETFramework 4.6.1
- PS.Primitives (>= 2.2.17)
-
.NETFramework 5.0
- PS.Primitives (>= 2.2.17)
-
.NETStandard 2.0
- PS.Primitives (>= 2.2.17)
- .NETFramework 4.6.1: 4.6.1.0
- .NETFramework 5.0: 5.0.0.0
- .NETStandard 2.0: 2.0.0.0
OwnersBlackGad |
AuthorsVolodymyr Shkolka |
Project URLhttps://github.com/BlackGad/PS.Framework |
LicenseUnknown |
TagsFramework MVVM Standard WPF |
Info177 total downloads |
4 downloads for version 2.2.17 |
Download (45.63 KB) |
Found on the current feed only |
Package history
Version | Size | Last updated | Downloads | Mirrored? | |||
---|---|---|---|---|---|---|---|
2.16.0 | 65.57 KB | Sat, 11 May 2024 07:13:38 GMT | 3 | ||||
2.15.0 | 50.4 KB | Sun, 08 Oct 2023 16:06:37 GMT | 4 | ||||
2.14.4 | 50.32 KB | Sun, 08 Oct 2023 16:02:37 GMT | 4 | ||||
2.13.3 | 47.36 KB | Wed, 12 Apr 2023 15:30:58 GMT | 4 | ||||
2.13.2 | 47.36 KB | Tue, 11 Apr 2023 12:38:01 GMT | 4 | ||||
2.13.1 | 47.35 KB | Sun, 09 Apr 2023 21:20:14 GMT | 3 | ||||
2.13.0 | 47.35 KB | Sat, 08 Apr 2023 12:47:45 GMT | 4 | ||||
2.11.0 | 47.32 KB | Thu, 15 Sep 2022 13:29:14 GMT | 4 | ||||
2.10.0 | 47.33 KB | Thu, 15 Sep 2022 13:20:04 GMT | 4 | ||||
2.9.14 | 47.34 KB | Thu, 15 Sep 2022 13:02:28 GMT | 4 | ||||
2.9.12 | 47.34 KB | Thu, 15 Sep 2022 12:42:00 GMT | 4 | ||||
2.9.11 | 46.73 KB | Mon, 12 Sep 2022 12:46:00 GMT | 4 | ||||
2.9.10 | 46.74 KB | Wed, 07 Sep 2022 10:36:41 GMT | 4 | ||||
2.9.9 | 46.68 KB | Wed, 07 Sep 2022 09:17:14 GMT | 4 | ||||
2.9.8 | 46.7 KB | Mon, 05 Sep 2022 12:09:24 GMT | 4 | ||||
2.9.6 | 46.69 KB | Mon, 05 Sep 2022 11:52:16 GMT | 4 | ||||
2.9.5 | 46.7 KB | Tue, 23 Aug 2022 13:06:12 GMT | 4 | ||||
2.9.4 | 46.7 KB | Fri, 19 Aug 2022 07:45:22 GMT | 4 | ||||
2.9.1 | 46.69 KB | Mon, 23 May 2022 13:33:40 GMT | 4 | ||||
2.7.1 | 46.69 KB | Sat, 14 May 2022 18:13:18 GMT | 4 | ||||
2.2.18 | 45.63 KB | Mon, 25 Oct 2021 15:45:20 GMT | 4 | ||||
2.2.17 | 45.63 KB | Mon, 25 Oct 2021 15:04:02 GMT | 4 | ||||
2.2.16 | 45.63 KB | Sat, 23 Oct 2021 14:47:35 GMT | 4 | ||||
2.2.15 | 45.63 KB | Fri, 22 Oct 2021 21:52:00 GMT | 4 | ||||
2.2.13 | 45.62 KB | Fri, 22 Oct 2021 17:57:04 GMT | 4 | ||||
2.2.12 | 45.62 KB | Sun, 17 Oct 2021 21:14:18 GMT | 4 | ||||
2.2.11 | 45.63 KB | Thu, 14 Oct 2021 12:50:55 GMT | 4 | ||||
2.2.9 | 45.58 KB | Wed, 13 Oct 2021 22:49:08 GMT | 4 | ||||
2.2.8 | 45.58 KB | Sat, 09 Oct 2021 23:02:07 GMT | 4 | ||||
2.2.5 | 45.58 KB | Sat, 02 Oct 2021 22:08:28 GMT | 4 | ||||
2.2.4 | 31.41 KB | Sat, 02 Oct 2021 21:19:42 GMT | 4 | ||||
2.2.3 | 31.4 KB | Wed, 29 Sep 2021 15:24:43 GMT | 4 | ||||
2.2.1 | 30.97 KB | Wed, 29 Sep 2021 14:06:58 GMT | 4 | ||||
2.0.4 | 31.01 KB | Sun, 21 Mar 2021 21:52:31 GMT | 4 | ||||
2.0.0 | 16.74 KB | Sun, 29 Mar 2020 19:06:28 GMT | 4 | ||||
1.11.2 | 30.04 KB | Sat, 23 Nov 2019 15:59:05 GMT | 3 | ||||
1.11.1 | 30.43 KB | Tue, 30 Jul 2019 20:39:33 GMT | 4 | ||||
1.11.0 | 20.94 KB | Sat, 27 Jul 2019 19:43:15 GMT | 4 | ||||
1.10.6 | 20.98 KB | Fri, 12 Jul 2019 14:30:51 GMT | 4 | ||||
1.10.5 | 20.98 KB | Thu, 11 Jul 2019 22:31:19 GMT | 4 | ||||
1.10.4 | 20.98 KB | Thu, 11 Jul 2019 21:53:07 GMT | 4 | ||||
1.10.3 | 20.98 KB | Thu, 11 Jul 2019 21:41:23 GMT | 4 | ||||
1.10.2 | 20.98 KB | Thu, 11 Jul 2019 20:51:22 GMT | 4 | ||||
1.10.1 | 20.97 KB | Thu, 11 Jul 2019 20:04:30 GMT | 4 | ||||
1.0.4 | 20.92 KB | Thu, 11 Jul 2019 13:10:29 GMT | 4 |