I'm developping a descktop application based en WPF (MVVM pattern) And i'm using MVVMLight-Toolkit, In my application there is a system of user authentication. The problem is: let's say that i have a ViewA, its dataContext is defined by a ViewModelA. Suppose tha User1 is logged to the application and navigates to the viewA, he does some stuff and after that he disconnects. when another user or the same user logon again and navigates to the same ViewA, he finds the lastest context of the previous user. I want to kill the instance of the ViewModel Created and create a new one for the new user. I tried to add a registration method to the ViewModelLocator
public static void RegisterViewModel<T>() where T : ViewModelBase
{
if (SimpleIoc.Default.IsRegistered<T>()
SimpleIoc.Default.Unregister<T>();
SimpleIoc.Default.Register<T>();
}
but it doesn't work, the context is stayed. can you help me to solve this problem ? thx