CM Micro support for Generic ViewModels

Oct 15, 2010 at 1:28 PM


Ran into this issue recently, and it can be fixed by slightly modifying/extending the ViewLocator.cs:

 public static Func<Type, DependencyObject, object, UIElement> LocateForModelType = (modelType, displayLocation, context) =>{
            var viewTypeName = modelType.FullName.Substring(0, modelType.FullName.IndexOf("`") < 0 ? modelType.FullName.Length : modelType.FullName.IndexOf("`")).Replace("Model", string.Empty);



For anyone that runs into this problem :D It cuts out the gunk that you get when you request the fullname of a viewmodel that has generic parameters.