[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
  [Expand]Services
  [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

ViewLocator

The ViewLocator class implements the IViewLocator interface and provides a simple composition mechanism to locate Views by their type names.

You can use the functionality provided by the ViewLocator class to locate a View from another object if this object does not have a direct link to the View.

To retrieve a View by its type name, you typically call the IViewLocator.ResolveView method on the Default static property:

where viewShortTypeName is the short type name of the View to be returned.

By default, the Default property contains a ViewLocator object capable of locating Views within the entry assembly. If you want the ViewLocator to locate Views within two or more assemblies, create a new ViewLocator object via a constructor that takes a list of assemblies as a parameter. Then, assign the created object to the Default property.

If the default ViewLocator implementation does not meet your requirements, you can implement a custom ViewLocator. For instance, the following ViewLocator retrieves a View from an assembly loaded on demand.

ViewLocator is used by Services. It provides the capability to create Views. Please review the following article for more details: View creation mechanisms.

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