[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
   [Collapse]Predefined Set
    [Expand]Dialog Services
    [Expand]Message Box Services
    [Expand]Document Services
    [Collapse]ViewInjectionService
      View Injection Service Concept
      View Injection Manager Concept
      Implementing Custom Strategy
    [Expand]Report Services
     NotificationService
     TaskbarButtonService
     ApplicationJumpListService
     DXSplashScreenService
     DispatcherService
     FrameNavigationService
     LayoutSerializationService
     FolderBrowserDialogService
     OpenFileDialogService
     SaveFileDialogService
     WizardService
     NotifyIconService
    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

ViewInjectionService

The ViewInjectionService is an IViewInjectionService implementation that allows you to integrate any ViewModel (with its View) to controls.

Note

You are viewing ViewInjectionService documentation. If you're starting a new project, we strongly recommend that you use Module Injection Framework (MIF).

Assume that you have several views with view models (CustomersView/CustomersViewModel, ProductsView/ ProductsViewModel and SalesView/SalesViewModel) that have to be shown in an items control.

To accomplish this task, place the items control (suppose, it's a FlipView control) on the MainView and add the ViewInjectionService to the control's dxmvvm:Interaction.Behaviors collection as usual.

Inject views with view models using the ViewInjectionManager's Inject method (To learn more about concepts of ViewInjectionService and ViewInjectionManager, refer to the View Injection Service Concept and View Injection Manager Concept topics respectively). For example, perform injections in the Startup event handler.

The Regions class is a static class with static string properties.

ModuleType is an enumeration:

The FlipView is populated. Add a navigation view to our MainView.

Inject items to the TileBar

The example application is almost ready. Synchronize the TileBar and FlipView, so they show the same element. To do this, use the RegisterNavigatedEventHandler.

By default, ViewInjectionService supports a fixed number of standard and DevExpress controls. However if necessary, you can extend it to work with your own controls. To learn how to do it, refer to Implementing Custom Strategy.

Expanded Example

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T220725.

Expanded See Also

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