Caliburn.Micro.Autofac
Caliburn.Micro.Autofac copied to clipboard
Not working, if ViewModelBaseType is a class (e.g. PropertyChangedBase)
The automatic registration of ViewModels is not working, if the ViewModelBaseType is set to a class and not an interface. To solve this problem you should change in the Configure method the registration of ViewModels to:
// register view models builder.RegisterAssemblyTypes(AssemblySource.Instance.ToArray()) // must be a type with a name that ends with ViewModel .Where(type => type.Name.EndsWith("ViewModel")) // must be in a namespace ending with ViewModels .Where(type => EnforceNamespaceConvention ? (!(string.IsNullOrWhiteSpace(type.Namespace)) && type.Namespace.EndsWith("ViewModels")) : true) // must implement INotifyPropertyChanged (deriving from PropertyChangedBase will statisfy this) ////.Where(type => type.GetInterface(ViewModelBaseType.Name, false) != null)
.Where(type => ViewModelBaseType.IsAssignableFrom(type))
// registered as self .AsSelf() // always create a new one .InstancePerDependency();