title: WPF - Prism eventAggregator doesn't work properly
body: <p>I'm trying to learn how to build a WPF application but I'm encountering some problems when I use the EventAggregator class. 
  Now I have the mainWindow.xaml that looks like: </p>
  
  <pre><code>&lt;Window.Resources&gt;
      &lt;DataTemplate DataType="{x:Type viewModel:LoginViewModel}"&gt;
          &lt;view:LoginView/&gt;
      &lt;/DataTemplate&gt;
      &lt;DataTemplate DataType="{x:Type viewModel:HomeViewModel}"&gt;
          &lt;view:HomeView/&gt;
      &lt;/DataTemplate&gt;
      &lt;DataTemplate DataType="{x:Type viewModel:ReportViewModel}"&gt;
          &lt;view:ReportView/&gt;
      &lt;/DataTemplate&gt;
  &lt;/Window.Resources&gt;
  &lt;Grid&gt;
      &lt;ContentControl Content="{Binding BaseViewModel}"/&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>So, my plan is switching views based on the value of the 'BaseViewModel' property.
  When I need to change the view I publish an event like:</p>
  
  <pre><code>User user = session.login(Username, password);
  if(user != null)
  {
      //publishing the event
       _eventAggregator.GetEvent&lt;OpenNewView().Publish((IBaseViewModel)container.Resolve&lt;IHomeViewModel&gt;());
  }
  </code></pre>
  
  <p>And I pass to the event the class I should switch to. The example above works fine, but when I try to replicate this behavior on another view model there is something that doesn't trigger. This is when I public the event again:</p>
  
  <pre><code>_eventAggregator.GetEvent&lt;OpenNewView&gt;().Publish((IBaseViewModel)container.Resolve&lt;IReportViewModel&gt;());
  </code></pre>
  
  <p>But this isn't trigger on MainWindowModel (when the line above is executed correctly). Here when I subscribe the event:</p>
  
  <pre><code>    //ctor
      public MainViewModel(ILoginViewModel viewModel, IEventAggregator eventAggregator)
      {
          _eventAggregator = eventAggregator;
          eventAggregator.GetEvent&lt;OpenNewView&gt;().Subscribe(OnOpenView);
          BaseViewModel = (LoginViewModel)viewModel;
      }
  </code></pre>
  
  <p>The method 'OnOpenView' is never executed.
  Here my 'OpenNewView' class:</p>
  
  <pre><code>public class OpenNewView : PubSubEvent&lt;IBaseViewModel&gt;
  {
  }
  </code></pre>
  
  <p>Note: 
  Here is how I declare the EventAggregator class (using Autofac):</p>
  
  <pre><code>builder.RegisterType&lt;EventAggregator&gt;().As&lt;IEventAggregator&gt;().SingleInstance();
  </code></pre>
  
  <p>So, I should have a single instance.</p>
  
  <p>I'm new to the WPF world so I'm not sure I'm following the best practices.</p>
  
  <p>Note 2: 
  An important thing I forgot to mention:
  if I replace the MainWindowViewModel constructor with:</p>
  
  <pre><code>    public MainViewModel(IHomeViewModel viewModel, IEventAggregator eventAggregator)
      {
          _eventAggregator = eventAggregator;
          eventAggregator.GetEvent&lt;OpenNewView&gt;().Subscribe(OnOpenView);
          BaseViewModel = (HomeViewModel)viewModel;
      }
  </code></pre>
  
  <p>the pair publish-subscribe start working on my HomeViewModel. And that's a little weird... </p>