title: Unable to programmatically read an updated user control property from within MainWindowViewModel
body: <p>I've following code in my WPF app.I'm dynamically rendering the user control in MainWindow using  ContentPresenter control on change of SelectedAccountType combobox value.
  I enter some value in MyProperty textbox in UI and click on Save button on MainWindow.But I dont see this value in the MainWindowViewModel.cs in the Save method(i.e. on click of Save button).
  All my ViewModels extend this abstract class:</p>
  
  <pre><code>public abstract class ViewModelBase : INotifyPropertyChanged, IDisposable
  </code></pre>
  
  <p>What am I missing here please?</p>
  
  <p>Thanks.</p>
  
  <p>Here's my code:</p>
  
  <p>MainWindow.xaml:</p>
  
  <pre><code>&lt;Window
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          xmlns:MainViewModel="clr-namespace:Test.ViewModel"
          xmlns:ViewModel="clr-namespace:Test.ViewModel.AccountTypes"
          xmlns:View="clr-namespace:Test.View" x:Class="Test.MainWindow"
          xmlns:Views="clr-namespace:Test.View.AccountTypes"
          xmlns:v="clr-namespace:Test.View.AccountTypes"
          xmlns:vm="clr-namespace:Test.ViewModel.AccountTypes"
          Title="{Binding DisplayName, Mode=OneWay}" ResizeMode="CanResize" WindowStartupLocation="CenterScreen"&gt;
      &lt;Window.DataContext&gt;
          &lt;MainViewModel:MainWindowViewModel/&gt;
      &lt;/Window.DataContext&gt;
  
      &lt;Grid&gt;
  
          &lt;StackPanel Grid.Row="0"  HorizontalAlignment="Left" VerticalAlignment="Top" Orientation="Horizontal" Height="28" Width="auto" Margin="5,0,0,0"&gt;
              &lt;ComboBox Width="360" Margin="1,0" ItemsSource="{Binding AccountTypes}" DisplayMemberPath="Code" SelectedValuePath="ID" SelectedItem="{Binding SelectedAccountType,
   Mode=TwoWay}" TabIndex="0" /&gt;
          &lt;/StackPanel&gt;
  
          &lt;ContentPresenter Content="{Binding CurrentViewModel}"&gt;
          &lt;ContentPresenter.Resources&gt;
                  &lt;DataTemplate DataType="{x:Type ViewModel:AC1ViewModel}"&gt;
                      &lt;Views:AC1View/&gt;
              &lt;/DataTemplate&gt;
                  &lt;DataTemplate DataType="{x:Type ViewModel:AC2ViewModel}"&gt;
                      &lt;Views:AC2View/&gt;
              &lt;/DataTemplate&gt;
          &lt;/ContentPresenter.Resources&gt;
      &lt;/ContentPresenter&gt;
          &lt;/Grid&gt;
  </code></pre>
  
  <p>MainWindowViewModel.cs</p>
  
  <pre><code>public object CurrentViewModel
  {
      get 
          { 
              return m_currentViewModel; 
          }
          set
              {
                  m_currentViewModel = value;
                  OnPropertyChanged("CurrentViewModel");    
              }
          }   
  
  
  public AccountType SelectedAccountType
  {
      get
      {
          return m_selectedSearchAccountType;
      }
      set
      {
          m_selectedSearchAccountType = value;
              if (SelectedAccountType.Code == "AC1")
          {
              CurrentViewModel  = new AC1ViewModel();
          }
          else if (SelectedAccountType.Code == "AC2")
          {
              CurrentViewModel  = new AC2ViewModel();
          }
      }
  }
  
  public void Save()
  {
          Type sourceType = CurrentViewModel.GetType();
          PropertyInfo[] sourcePI = sourceType.GetProperties();
  
          Type destinationType = securityDetails.GetType();
          PropertyInfo[] destinationPI = destinationType.GetProperties();
  
          string propertyName = string.Empty;
          object propertyValue = null;
  
          foreach (var pinfo in sourcePI)
          {
              propertyName = pinfo.Name.Trim();
              propertyValue = pinfo.GetValue(CurrentViewModel)
          }
  }
  </code></pre>
  
  <p>AC1View.xaml:</p>
  
  <pre><code>&lt;TextBox HorizontalAlignment="Left" Height="23" Margin="1,1,0,0" VerticalAlignment="Top" Width="230" TabIndex="1" Text="{Binding MyProperty,UpdateSourceTrigger=PropertyChanged}" /&gt;
  </code></pre>
  
  <p>AC1ViewModel.cs</p>
  
  <pre><code>public class AC1ViewModel
  {
      private string m_myProperty = "";
      public AC1ViewModel()
      {
  
      }
  
  
      public string MyProperty
      {
          get
          {
              return m_myProperty;
          }
          set
          {
              m_myProperty = value;
          }
      }
  
  }
  </code></pre>