0

Okay, so I'm not all too good with this kind of thing. I currently have the following for configuring my view model locator in the bootstrapper.

            ViewModelLocationProvider.SetDefaultViewTypeToViewModelTypeResolver(viewType =>
            {
                var viewName = viewType.FullName;
                viewName = viewName.Replace("Views", "ViewModels");
                var viewAssemblyName = viewType.GetTypeInfo().Assembly.FullName;
                var viewModelName = string.Format(CultureInfo.InvariantCulture, " {0}Model, {1} ", viewName,
                    viewAssemblyName);
                return Type.GetType(viewModelName);
            });

            ViewModelLocationProvider.SetDefaultViewModelFactory(type => Kernel.Get(type));

To my understanding, this searches the assembly the view is in, and binds the datacontext of any views ending in view, to the matching named viewmodel. (sorry I'm terrible at explaining these things too)

However we want to separate the modules even further. Could anyone explain to me a way we could link the view models to the views if they reside in a different project?

IE if I had the two projects

ModuleA.Views
ModuleA.ViewModels

I'd want to bind the viewmodels from one project, to the views of the other. Is this doable? And if it is, how would one do this? Any help would be appreciated.

user3265613
  • 355
  • 2
  • 14
  • What could possibly be the benefit of having your views in a separate assembly from the view models? And if you bring up SOLID, I will call BS. This goes beyond principles into lunacy. Just my opinion. Next thing you know, you have a separate assembly for each class. Ridiculous. – R. Richards Jan 26 '17 at 20:14
  • It was mostly an idea for if we wanted to switch out our view system for something different (uwp, xamarin forms etc) so we could keep the bulk of the back end and only need to change the front end code. I personally agree with you, but i'm trying to carry out orders from above. – user3265613 Jan 27 '17 at 11:41

0 Answers0