title: RegisterType with EventAggregator and ViewModel
body: <p>I do not understand how we register an <code>IEventAggregator</code> instance so we can inject it into a <code>ViewModel</code>.</p>
  
  <p>Example:</p>
  
  <p>I define my <code>MainViewModel</code>:</p>
  
  <pre><code>...
  private IEventAggregator _eventAggregator;
  
  public MainViewModel(IEventAggregator eventAggregator) {
      _eventAggregator = eventAggregator;
      ...
  }
  ...
  </code></pre>
  
  <p>Then, I need to somehow register a class that implements <code>IEventAggregator</code> that I want to inject in my <code>ViewModel</code>.</p>
  
  <p>In my <code>ModuleInit</code> class, I would have something like this:</p>
  
  <pre><code>...
  private IUnityContainer _container;
  
  public ModuleInit(IUnityContainer _container) {
     _container = container;
  }
  ...
  public void Initialize() {
     container.RegisterType&lt;IEventAggregator, ___(something)___&gt;();
     ...
  }
  </code></pre>
  
  <p>In my <code>MainViewModel</code> class, I can also implement <code>_eventAggregator = ServiceLocator,Current.GetInstance&lt;IEventAggregator&gt;();</code>, but I don't really understand conceptually what I'm doing. The program just works...</p>
  
  <p>I would really like to understand what <code>ServiceLocator</code> is actually doing, and what I should be doing to appropriately register a type with my container. I don't define a class the implements <code>IEventAggregator</code>, so where is <code>ServiceLocator</code> getting the instance? And what would I then have to register so that when I resolve something, like my <code>ViewModel</code>, it will create a new <code>EventAggregator</code> instance?</p>