title: ComboBox binding - SelectedItem lost after ViewModel change
body: <h1>The situation</h1>
  
  <h2>Main Window and ContentControl</h2>
  
  <p>I have a MainWindow with a HamburgerMenu at the left. The DataContext of MainWindow is MainViewModel. </p>
  
  <p>Therein are commands defined to switch between the ViewModels of the 'child views' which are displayed in the center area of MainWindow using a ContentControl. The commands are bound to the HamburgerMenu to perform the view model switching. They are defined inside the constructor of MainViewModel like this:</p>
  
  <pre><code>CmdOpenMethodView = new RelayCommand(p =&gt;
  {
    if (MethodVM == null)
    {
      MethodVM = new MethodViewModel();
    }
  
    CurrentViewModel = MethodVM;
  
  }, p =&gt; !(CurrentViewModel is MethodViewModel));
  
  CmdOpenSettingsView = new RelayCommand(p =&gt;
  {
    if (SettingsVM == null)
    {
      SettingsVM = new SettingsViewModel();
    }
  
    CurrentViewModel = SettingsVM;
  
  }, p =&gt; !(CurrentViewModel is SettingsViewModel));
  </code></pre>
  
  <p>The ContentControl is bound to property CurrentViewModel (of type BaseViewModel) which is defined in MainViewModel.</p>
  
  <p>The MainWindow.xaml (without header) goes like this:</p>
  
  <pre><code>&lt;Window.DataContext&gt;
    &lt;ViewModels:MainViewModel/&gt;
  &lt;/Window.DataContext&gt;
  
  &lt;Grid&gt;
    &lt;Grid.ColumnDefinitions&gt;
      &lt;ColumnDefinition Width="Auto"/&gt;
      &lt;ColumnDefinition Width="*"/&gt;
    &lt;/Grid.ColumnDefinitions&gt;
    &lt;HamburgerMenu:HamburgerMenu Grid.Column="0"
                                 Background="#6080bc" 
                                 MenuIconColor="White"
                                 SelectionIndicatorColor="White" 
                                 MenuItemForeground="White" 
                                 MaxWidth="130"
                                 HorizontalAlignment="Left"&gt;
      &lt;HamburgerMenu:HamburgerMenuItem Text="Method" 
                                       SelectionCommand="{Binding CmdOpenMethodView}"/&gt;
  
      &lt;HamburgerMenu:HamburgerMenuItem Text="Settings" 
                                       SelectionCommand="{Binding CmdOpenSettingsView}"/&gt;
    &lt;/HamburgerMenu:HamburgerMenu&gt;
    &lt;ScrollViewer Grid.Column="2" VerticalScrollBarVisibility="Auto"&gt;
      &lt;ContentControl  Content="{Binding CurrentViewModel}"/&gt;
    &lt;/ScrollViewer&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>The connection between the child view &lt;-> view models is set up in App.xaml as follows:</p>
  
  <pre><code>&lt;Application.Resources&gt;
    &lt;!--Wire the view models and views--&gt;
    &lt;DataTemplate DataType="{x:Type ViewModels:MainViewModel}"&gt;
      &lt;Views:MainView /&gt;
    &lt;/DataTemplate&gt;
    &lt;DataTemplate DataType="{x:Type ViewModels:MethodViewModel}"&gt;
      &lt;Views:MethodView /&gt;
    &lt;/DataTemplate&gt;
    &lt;DataTemplate DataType="{x:Type ViewModels:SettingsViewModel}"&gt;
      &lt;Views:SettingsView /&gt;
    &lt;/DataTemplate&gt;
  &lt;/Application.Resources&gt;
  </code></pre>
  
  <h2>Child controls</h2>
  
  <p>So, the center area of MainWindow displays either MethodView or SettingsView.</p>
  
  <p>MethodsView contains a ComboBox which is bound to a property 'CurrentMethod' of MethodViewModel like this:</p>
  
  <pre><code>&lt;ComboBox DisplayMemberPath="Name"
            IsSynchronizedWithCurrentItem="True"
            SelectedItem="{Binding CurrentMethod, 
                           UpdateSourceTrigger=PropertyChanged}"
            ItemsSource="{Binding AllMethodsView}"
            IsEnabled="{Binding IsMenuAllowed}"
            Grid.Row="0" Grid.Column="1"/&gt;
  </code></pre>
  
  <p>The ItemsSource is set to MethodViewModel.AllMethodsView which is of type ListCollectionView. The SelectedItem is bound to MethodViewModel.CurrentMethod of my custom type Method.</p>
  
  <h1>The problem</h1>
  
  <p>When clicking in the MainMenu/HamburgerMenu to open the settings view, the settings view opens.</p>
  
  <p>When then clicking to open the methods view again, the methods view opens but the combobox has forgotten its selected item. </p>
  
  <p>In debugging MethodViewModel I see the ListCollectionView.CurrentItem is set to null when the ContentView switches to display SettingsView. </p>
  
  <p>How can I prevent this?</p>
  
  <p><strong>Edit:</strong> 
  I added an example to <a href="https://github.com/rosneru/ChangeViewsMVVM" rel="nofollow noreferrer">GitHub</a> to provide a demonstration app.</p>
  
  <p>Not sure if it builds out of the box, but the source is there, and maybe somebody has an idea how to solve the problem?</p>