Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ViewLocator can't resolve views specified by UWP RoutedViewHost #1299

Closed
olevett opened this issue Feb 28, 2017 · 0 comments
Closed

ViewLocator can't resolve views specified by UWP RoutedViewHost #1299

olevett opened this issue Feb 28, 2017 · 0 comments

Comments

@olevett
Copy link
Member

olevett commented Feb 28, 2017

Note: for support questions, please ask on StackOverflow: https://stackoverflow.com/questions/tagged/reactiveui . This repository's issues are reserved for feature requests and bug reports.

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
RoutedViewHost on UWP uses the IRoutableViewModel type to specify what view model type to return for ViewLocator calls, which ends up failing

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem

public interface IRoutableFooViewModel : IRoutableViewModel { }

public class RoutableFooViewModel : ReactiveObject, IRoutableFooViewModel
{
    public IScreen HostScreen { get; set; }
    public string UrlPathSegment { get; set; }
}

public class RoutableFooView : IViewFor<IRoutableFooViewModel>
{
    object IViewFor.ViewModel
    {
        get { return ViewModel; }
        set { ViewModel = (IRoutableFooViewModel)value; }
    }
    public IRoutableFooViewModel ViewModel { get; set; }
}

public void CanResolveViewFromViewModelWithIRoutableViewModelType()
{
	var resolver = new ModernDependencyResolver();

	resolver.InitializeSplat();
	resolver.InitializeReactiveUI();
	resolver.Register(() => new RoutableFooView(), typeof(IViewFor<IRoutableFooViewModel>));

	using (resolver.WithResolver()) {
		var fixture = new DefaultViewLocator();
		var vm = new RoutableFooViewModel();

		var result = fixture.ResolveView<IRoutableViewModel>(vm);
		Assert.IsType<RoutableFooView>(result);
	}
}

What is the expected behavior?
That this type can be resolved...

What is the motivation / use case for changing the behavior?

Which versions of ReactiveUI, and which platform / OS are affected by this issue? Did this work in previous versions of ReativeUI? Please also test with the latest stable and snapshot (http://docs.reactiveui.net/en/contributing/snapshot/index.html) versions.
Any version other than 7.2.

Other information (e.g. stacktraces, related issues, suggestions how to fix)
I think the only change required would be to change ViewLocator to use GetType() rather than typeof(T) on line 170.

@olevett olevett mentioned this issue Mar 7, 2017
2 tasks
@kentcb kentcb closed this as completed in 0c2ef95 May 23, 2017
@ghuntley ghuntley modified the milestones: vNext, 7.4.0 May 23, 2017
@lock lock bot added the outdated label Jun 24, 2019
@lock lock bot locked and limited conversation to collaborators Jun 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants