There is!
By default, objects allowed from SimpleIoc are single. To get around this, you need to pass a unique identifier as a parameter to the ServiceLocator.GetInstance method.
See below:
We have two properties that return the same presentation model. One returns singleton, and the other returns each new instance.
class ViewModelLocator { static ViewModelLocator() { ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); if (ViewModelBase.IsInDesignModeStatic) { SimpleIoc.Default.Register<IDataService, Design.DesignDataService>(); } else { SimpleIoc.Default.Register<IDataService, DataService>(); } SimpleIoc.Default.Register<MainViewModel>(); SimpleIoc.Default.Register<SecondViewModel>(); } public MainViewModel MainAsSingleton { get { return ServiceLocator.Current.GetInstance<MainViewModel>(); } } public MainViewModel MainAsDiffrentInstanceEachTime { get { return ServiceLocator.Current.GetInstance<MainViewModel>(Guid.NewGuid().ToString()); } } }
source share