Routing documentation AppViewLocator error
Yot360 opened this issue · 0 comments
Yot360 commented
In the ReactiveUI Routing Avalonia documentation, there is an error in the code.
The error is located in the AppViewLocator.cs
file:
File in docs:
namespace RoutingExample
{
public class AppViewLocator : ReactiveUI.IViewLocator
{
public IViewFor ResolveView<T>(T viewModel, string contract = null) where T : class => viewModel switch
{
FirstViewModel context => new FirstView { DataContext = context },
_ => throw new ArgumentOutOfRangeException(nameof(viewModel))
};
}
}
The error:
The error is that the interface IViewLocator.cs doesn't have a class constraint on T in the interface.
The fixed code:
namespace RoutingExample
{
public class AppViewLocator : ReactiveUI.IViewLocator
{
public IViewFor ResolveView<T>(T viewModel, string contract = null) => viewModel switch
{
FirstViewModel context => new FirstView { DataContext = context },
_ => throw new ArgumentOutOfRangeException(nameof(viewModel))
};
}
}