Skip to content

[BUG] IViewLocator.ResolveView<T> return value documentation misleading for DefaultViewLocator.ResolveView<T> implementation #2451

@lizalc

Description

@lizalc

Describe the bug
The documentation for IViewLocator.ResolveViewFor<T> describes the return value as:

/// <returns>The view, with the ViewModel property assigned to
/// viewModel.</returns>

Given this, one would expect that when resolving a view with the default view locator via ViewLocator.Current.ResolveView(viewModel) the returned view would have the provided viewModel assigned to its ViewModel property. However this isn't the case as the DefaultViewLocator.ResolveViewFor<T> does not ever assign the provided viewModel to the view's ViewModel property.

Granted, the documentation for DefaultViewLocator.ResolveViewFor<T> doesn't mention that it will assign the view's ViewModel property and this could be the expected behavior for the DefaultViewLocator. It's just a bit confusing to have the documentation for IViewLocator.ResolveViewFor<T> claiming that the provided viewModel will be assigned to the view's ViewModel property and then have the DefaultViewLocator.ResolveViewFor<T> implementation not actually do that.

Steps To Reproduce

  1. Create a view model instance (viewModel).
  2. Call ViewLocator.Current.ResolveView(viewModel) to get the view for the viewModel.
  3. Observe that the returned view's ViewModel property has not been set.

Expected behavior
The view returned by the ViewLocator.Current.ResolveView(viewModel) call should have its ViewModel property set to the provided viewModel.

Or, the documentation for IViewLocator.ResolveView<T> should not state the ViewModel property will be set.

Environment

  • OS: Windows 10
  • Version: 2004
  • Device: PC

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions