title: NotifyPropertyChanged and ContentControl
body: <p>I am struggling for one week now with my problem and i cant solve it. I am programming a MVVM WPF application which is having one window (MainView). In This <code>Mainview</code> i want to load different <code>UserControl</code> when i need them. In the <code>Application-Startup</code> I am loading the <code>MainViewModel</code>. In the Constructor of the <code>MainViewModel</code> I am loading the First <code>ViewModel</code> (<code>LoginViewModel</code>). Cause of my <code>MainView.xaml</code> it is showing me my <code>Login-User-Control</code> like i want to. So till this point everything is fine. In the <code>ActivePanel-class</code> i am saving the <code>CurrentView</code>, because in my <code>MainView.xaml</code> i am making a binding to my <code>CurrentView</code> for the <code>ContentControl</code>. So everything is working except the changing of the views although my <code>NotifyPropertyChanged</code> method of the <code>CurrentView</code> is working. I am thinking, that my mistake is in the <code>xaml</code> (DataBinding). Hope you guys can help me. </p>
  
  <p>This is my <code>MainView.xaml</code> in which i want to load the different DataTemplates. Like I said before: The loading of the <code>LoginViewModel</code> via the Constructor of <code>MainViewModel</code> is working. The changing to other <code>VieModels</code> is working as well, but the DataBinding to the <code>ContentControl</code> is the big problem here.</p>
  
  <pre><code>&lt;Window x:Class="App.View.MainView"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
          xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
          xmlns:local="clr-namespace:App.View"
          mc:Ignorable="d"
          xmlns:viewmodels="clr-namespace:App.ViewModels"
          xmlns:views="clr-namespace:App.View"
          xmlns:helper="clr-namespace:App.Helper"
          Title="Betrooms" Height="500" Width="350"&gt;
  
      &lt;Window.Resources&gt;
          &lt;DataTemplate x:Name="LoginUCTemplate" DataType="{x:Type viewmodels:LoginViewModel}"&gt;
              &lt;views:LoginUC DataContext="{Binding}"/&gt;
          &lt;/DataTemplate&gt;
  
          &lt;DataTemplate x:Name="RegUCTemplate" DataType="{x:Type viewmodels:RegViewModel}"&gt;
              &lt;views:RegUC DataContext="{Binding}"/&gt;
          &lt;/DataTemplate&gt;
  
          &lt;DataTemplate x:Name="HomeUCTemplate" DataType="{x:Type viewmodels:HomeViewModel}"&gt;
              &lt;views:HomeUC DataContext="{Binding}"/&gt;
          &lt;/DataTemplate&gt;
      &lt;/Window.Resources&gt;
  
      &lt;Window.DataContext&gt;
          &lt;viewmodels:ActivePanel/&gt;
      &lt;/Window.DataContext&gt;
  
      &lt;Grid&gt;
          &lt;ContentControl Content="{Binding CurrentView, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}"/&gt;
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>This is the class of my <code>ActivePanel</code> where i am saving the information about which <code>ViewModel</code> is the active one. The <code>CurrentView</code> is the property I am binding the Content Control to.</p>
  
  <pre><code>namespace APP.ViewModels
  {
      public class ActivePanel : NotifyPropertyChanged
      {
          private object _currentView;
  
          public object CurrentView
          {
              get { return _currentView; }
              set
              {
                  if (value != _currentView)
                  {
                      _currentView = value;
                      OnPropertyChanged("CurrentView");
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>This is my <code>MainViewModel</code>:</p>
  
  <pre><code>namespace App.ViewModels
  {
      public class MainViewModel : ActivePanel
      {
          private LoginViewModel _loginViewModel;
  
          public MainViewModel()
          {
              _loginViewModel = new LoginViewModel();
              CurrentView = _loginViewModel;
          }
      }
  }
  </code></pre>
  
  <p>And this is my <code>LoginViewModel</code> where I am changing the value of <code>CurrentView</code> via an action:</p>
  
  <pre><code>namespace App.ViewModels
  {
      public class LoginViewModel : ActivePanel
      {
          #region Member
          private string _username;
          private string _password;
          bool login = false;
  
          private HomeViewModel _homeViewModel;
          private RegViewModel _regViewModel;
  
          UserModel User = new UserModel();
          #endregion
  
          #region Properties
          public ICommand RegActionCommand { get; set; }
          public ICommand LogActionCommand { get; set; }
  
          public string GetUsername
          {
              get { return _username; }
              set
              {
                  if (value != _username)
                  {
                      _username = value;
                      OnPropertyChanged("GetUsername");
                  }
              }
          }
  
          public string GetPassword
          {
              get { return _password; }
              set
              {
                  if (value != _password)
                  {
                      _password = value;
                      OnPropertyChanged("GetPassword");
                  }
              }
          }
          #endregion
  
          #region Constructor
          public LoginViewModel()
          {
              this.RegActionCommand = new RelayCommand(RegAction);
              this.LogActionCommand = new RelayCommand(LogAction);
          }
          #endregion
  
          #region Button-Action
          private void LogAction(object obj)
          {               
                  _homeViewModel = new HomeViewModel();
                  CurrentView = _homeViewModel;
          }
  
          private void RegAction(object obj)
          {
              _regViewModel = new RegViewModel();
              CurrentView = _regViewModel;
          }
          #endregion           
      }
  }
  </code></pre>
  
  <p>I hope my question is understandable: The <code>ContenControl</code> binding is set to <code>CurrentView</code> but the <code>ContentControl</code> is never changing although the property of <code>CurrentView</code> is changing.</p>
  
  <p>Thanks to you all. Cheers, Paul.</p>