title: MVVM OnPropertyChanged not changing view when using assignment operator (PropertyChanged becomes null)
body: <p>I'm trying to create an undo/redo system. Currently, when the user does something the original object and the new object are copied in a list per "action". If I press the undo button I want to assign the original value to the new value again.</p>
  
  <p>I've been able to get both the new and the original object in the list but it goes wrong when assigning the old object again by using the undo I made. It gets updated in the main list that holds all the objects that can be changed but it isn't updating in the view.</p>
  
  <p>This is how do the undo method:</p>
  
  <pre><code>for (int t = 0; t &lt; mainData.GroupModelList.Count; ++t)
  {
      if (mainData.GroupModelList[t].Name == commandList.ElementAt(position).groupModelNew.Name)
      {
          mainData.GroupModelList[t] = new ViewModels.GroupViewModel(commandList.ElementAt(position).groupModelOrig);
          break;
      }
  }
  </code></pre>
  
  <p>This calls the constructor of the GroupViewModel:</p>
  
  <pre><code>public GroupViewModel(GroupViewModel selectedGroup)
  { 
      groupModel = new GroupModel();
  
      // values are assigned from the selectedGroup here (which is the original object in the UndoRedo part)
      // ...
  
      OnPropertyChanged(null);
   }
  </code></pre>
  
  <p>This is the OnPropertyChanged method:</p>
  
  <pre><code>private void OnPropertyChanged(string Property)
  {
      if (PropertyChanged != null)
      {
          PropertyChanged(this, new PropertyChangedEventArgs(Property));
      }
  } 
  </code></pre>
  
  <p>I've read somewhere that using "null" at <code>PropertyChangedEventArgs</code> makes everything update, so that's what I tried but it isn't working.<br>
  After some more breakpoints I noticed that <code>PropertyChanged</code> is null when the new constructor is called, which is probably the problem. It does work without the Undo/Redo though. (When simply changing values the object holds using a textbox or similar)</p>
  
  <p>I've also read that I should point the DataContext to the object itself but that doesn't seem to be possible since the object doesn't have a DataContext property.</p>
  
  <p>EDIT: people have told me I should use ObservableCollection. I am already using that though. Like this: (This is the list the View has access to)</p>
  
  <pre><code>private ObservableCollection&lt;GroupViewModel&gt; groupModelList = new ObservableCollection&lt;GroupViewModel&gt;();
  public ObservableCollection&lt;GroupViewModel&gt; GroupModelList
  {
      get { return groupModelList; }
  }
  </code></pre>
  
  <p>EDIT: This is how the binding is done to the View:<br>
  First of all here's the binding in XAML</p>
  
  <pre><code>&lt;Window.Resources&gt;
      &lt;vm:MainViewModel x:Key="MainViewModel" /&gt;
  &lt;/Window.Resources&gt;
  </code></pre>
  
  <p><code>MainViewModel</code> holds an object of type <code>MainData</code> and inside that class there's an <code>ObservableCollection&lt;GroupViewModel&gt;</code>.<br>
  For example, this is the code that binds the name of the selected item from the list to a textbox in the View: (First line is the ListBox that shows all items in the GroupViewModel list, second one is the TextBox I want to give as an example)</p>
  
  <pre><code>&lt;ListBox DisplayMemberPath="Name" Height="412" HorizontalAlignment="Left" ItemsSource="{Binding Source={StaticResource MainViewModel}, Path=mainData.FilteredGroupModelList, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="10,44,0,0" Name="lbFoundItems" SelectedItem="{Binding Source={StaticResource MainViewModel}, Path=SelectedGroup, Mode=OneWayToSource}" VerticalAlignment="Top" Width="250" SelectionMode="Single" /&gt;
  
  &lt;ComboBox Height="23" HorizontalAlignment="Left" ItemsSource="{Binding ElementName=lbFoundItems, Path=SelectedItem.Types, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Margin="436,378,0,0" Name="cmbTypes" SelectedItem="{Binding Source={StaticResource MainViewModel}, Path=SelectedType, Mode=OneWayToSource}" VerticalAlignment="Top" Width="180" /&gt;
  </code></pre>
  
  <p>Also this is the <code>SelectedGroup</code> variable that holds a reference to the selected item in the ListBox:</p>
  
  <pre><code>private GroupViewModel selectedGroup;
  public GroupViewModel SelectedGroup
  {
      get { return selectedGroup; }
      set
      {
          selectedGroup = value;
          OnPropertyChanged("SelectedGroup");
      }
  }
  </code></pre>