IViewLocator

Name Value
Assembly Catel.MVVM
Namespace Catel.MVVM
Available on .NET Framework 4.5, .NET Framework 4.6, Portable Class Libraries, Xamarin - Android, Xamarin - iOS
public interface IViewLocator : ILocator

Implements interfaces ILocator

Resolver that will resolve view types based on the view model type. For example, if a view model with the type nameMyAssembly.ViewModels.PersonViewModel is inserted, this could result in the view typeMyAssembly.Views.PersonView.

Methods

IsCompatible(Type viewModelType, Type viewType)

Determines whether the specified view type is compatible with the view model. A view is compatible if it’s either resolved via naming conventions or registered manually.

Parameters

Name Description
viewModelType Type of the view model.
viewType Type of the view.

Returns

true if the view is compatible with the view model; otherwise,false.

Register(Type viewModelType, Type viewType)

Registers the specified view in the local cache. This cache will also be used by the ResolveView(Type) method.

Parameters

Name Description
viewModelType Type of the view model.
viewType Type of the view.

Exceptions

Name Description
ArgumentNullException The viewModelType isnull.

ResolveView(Type viewModelType)

Resolves a view type by the view model and the registered NamingConventions.

Parameters

Name Description
viewModelType Type of the view model to resolve the view for.

Returns

The resolved view ornull if the view could not be resolved.

Exceptions

Name Description
ArgumentNullException The viewModelType isnull.

Remarks

Keep in mind that all results are cached. The cache itself is not automatically cleared when the NamingConventions are changed. If the NamingConventions are changed, the cache must be cleared manually.


Have a question about Catel? Use StackOverflow with the Catel tag!


Discussion