1
Vote

SimpleIoC Unregister type detection

description

Hi,

All my view models inherit ViewModelBase. When I close some views, I want to unregister the type, so that an uncached version is instantiated upon the next request. So in my ViewModelLocator I do a Cleanup when the view is closed for these applicable views:
public static void Cleanup(ViewModelBase vm)
{
    SimpleIoc.Default.Unregister(vm);
}
This fails to unregister the applicable view model. Looking at the source, I see that the method uses typeof(TClass) (which yields ViewModelBase) to unregister the class. If it were used .GetType() the correct view model class would be returned and that works.

PR submitted at https://mvvmlight.codeplex.com/SourceControl/network/forks/igitur/MVVMLight/contribution/8434

comments

lbugnion wrote Dec 7, 2016 at 3:10 PM

I'll check it out, thanks

Laurent