[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]MVVM Framework
  [Expand]ViewModels
  [Expand]Commands
  [Expand]Behaviors
  [Collapse]Services
    Getting Started
    Services in ViewModelBase descendants
    Services in POCO objects
    Services in custom ViewModels
    View creation mechanisms
   [Expand]Predefined Set
    How to create a Custom Service
  [Expand]DXBinding
  [Expand]MIF
   Converters
   ViewLocator
   Messenger
   Data Annotation Attributes
   LayoutTreeHelper
   Weak Event
 [Expand]Controls and Libraries
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Services in POCO objects

The POCO mechanism provides the capability to gain access to Services. The code below is an example of how to do this.

To control the generation of service properties, use the ServiceProperty attribute or Fluent API. For instance, you can define several services of the same type and access a specific service by its name.

As an alternative way, you can manually define properties to access services. For this, define a non-virtual property and use one of POCOViewModelExtensions' GetService extension methods as shown in the code snippet below.

View Models can be related to each other with the parent-child relationship. This is achieved with the ISupportParentViewModel interface that is automatically implemented when you create a POCO object with the ViewModelSource class. You can pass the main View Model to the child using the ISupportParentViewModel.ParentViewModel property. This allows the child View Model to access Services that are registered for the main View Model. Please review the following topic for more information about this mechanism: ViewModel relationships (ISupportParentViewModel).

Here is an example that demonstrates the use of services when POCO View Models are related to each other with the parent-child relationship: DXMessageBoxService.

Is this topic helpful?​​​​​​​