I'm trying to create a generic method where the type is a generic interface.
private void ShowView<T>(string viewName) where T : IView<Screen>
{
IRegion mainRegion = _regionManager.Regions[RegionNames.MainRegion];
T view = (T)mainRegion.GetView(viewName);
if (view == null)
{
view = _container.Resolve<T>();
mainRegion.Add(view, viewName);
}
mainRegion.Activate(view);
view.LoadData();
view.ViewModel.IsActive = true;
}
Interface is IView<T> where T : Screen.
So I have ConcreteView : IView<ConcreteViewModel> and ConcreteViewModel : Screen where Screen is the base class. When I try to do ShowView<ConcreteView>("concrete"); I get an UnknownMethod error.
Is it because ConcreteView uses ConcreteViewModel instead of Screen for it's IView implementation? Is there a way to rewrite the method so that it works?