Dependency registration in SimpleIoc, by default uses Lazy Instantiation, meaning the object won’t be created until it is requested, in this case, via the property on the ViewModelLocator class.
Due to configuring subscription of a message type in the Constructors of my ViewModels in MVVM Light I recently came across a situation whereby messages were being published prior to them having been subscribed to, meaning that the messages disappeared into the void unhandled. The ViewModels relating to the pages I had navigated to were available in the ServiceLocator, but the pages that I hadn’t navigated to were not being instantiated.
Continue reading “Eager Instantiation of ViewModels with MVVM Light Messaging”