title: Change selected tab from ViewModel And send objects between ViewModels
body: <p>I got a  wpf desktop application with 3 ViewModels.
  I have 1 ViewModel that contains a tabhost and tabs. And I got 2 tabs. Each of those tabs has it's own ViewModel.<br />
  The problem I have is that in tab1 I have a listview with searchresults and a button. When I select one item in that list and press the button, I want to change tab and display information about that item I selected in tab2.<br />
  I have searched for a solution, but it seems to include creating all ViewModels in the MainViewModel and providing a reference of the MainViewModel to all the subViewModels.<br />
  Is there no other way?</p>
  
  <hr>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <p>I just managed to solve my problems with MVVM light that I added to the project.</p>
  
  <p>By binding a method in the MainViewModel and a property in it to the .xaml I can now call it from tab1 with info to tell it to change tab.
  Also, by binding a method in tab2 I can now send over an item from tab1 in the same manner.</p>
  
  <p><em>This is how I solved it after importing MVVM light into the project.</em><br/>
  <strong>In tab1</strong><br/></p>
  
  <pre><code>Messenger.Default.Send&lt;string, tab2ViewModel&gt;(--object to send to tab2--);
  Messenger.Default.Send&lt;int, MainViewModel&gt;(--tab index--);
  </code></pre>
  
  <p><strong>In Main/tab2</strong></p>
  
  <pre><code>Messenger.Default.Register&lt;int&gt;(this, ChangeTab);
  public void ChangeTab(int i)
  {
     SelectedTabIndex = i; //Bound property in .xaml
  }
  </code></pre>
  
  <p>It seems to automagically just work..</p>
  
  <p>P.s. Thanx for reply. I shall look into how Prism work as well, and see if there is any advantages to use that instead of MVVM light(Not right now however).</p>