title: In IoC (constructor injection), when does the injected contructor's instance is created?
body: <p>This is a sample code to demonstrate my question. I have removed other irrelevant codes for simplicity.</p>
  
  <pre><code>public class ViewModelLocator
  {
      static ViewModelLocator()
      {
          ServiceLocator.SetLocatorProvider(() =&gt; SimpleIoc.Default);
  
          if (ViewModelBase.IsInDesignModeStatic)
          {
              SimpleIoc.Default.Register&lt;IDataService, DesignDataService&gt;();
          }
          else
          {
              SimpleIoc.Default.Register&lt;IDataService, DataService&gt;();
  
          }
          SimpleIoc.Default.Register&lt;MainViewModel&gt;();
      }
  
      public MainViewModel Main
      {
          get
          {
              return ServiceLocator.Current.GetInstance&lt;MainViewModel&gt;();
          }
      }
  }
  </code></pre>
  
  <p>Based on my understanding  in the code above, if the application is in design mode, when a method/constructor needs a parameter of type IDataService, an instance of DesignDataService is passed as parameter and an instance of DataService otherwise. Now, my question is when does the instance of type IDataService is created? Is it possible for the object of type IDataService to have a parameter in its constructor?</p>
  
  <p>PS: I am new to wpf, MVVM pattern and the concept of Ioc. So please explain it in simple terms. Thanks.</p>