title: Property bound to DataGrid's SelectedItem does not change its child properties when CellEditEnding is fired
body: <p>I have a DataGrid which looks like:</p>
  
  <pre><code>&lt;DataGrid Grid.Row="3" Grid.Column="1" ItemsSource="{Binding Purchases}" SelectionMode="Single" SelectionUnit="FullRow"
            SelectedItem="{Binding SelectedPurchase, Source={x:Static ex:ServiceLocator.Instance}}" 
            AutoGenerateColumns="False" CanUserAddRows="False"&gt;
  
      &lt;e:Interaction.Triggers&gt;
          &lt;e:EventTrigger EventName="CellEditEnding"&gt;
              &lt;e:InvokeCommandAction Command="{Binding DataContext.CellEditEndingCommand, 
                                                       RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Page}}}"/&gt;
          &lt;/e:EventTrigger&gt;
      &lt;/e:Interaction.Triggers&gt;
  
      &lt;DataGrid.Columns&gt;
          .......
          ........
      &lt;DataGrid.Columns&gt;
  
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>Property SelectedPurchase looks like:</p>
  
  <pre><code>private Purchase _selectedPurchase;
  public Purchase SelectedPurchase
  {
      get
      {
          return _selectedPurchase;
      }
      set
      {
          _selectedPurchase = value;
          NotifyPropertyChanged("SelectedPurchase");
      }
  }
  </code></pre>
  
  <p>CellEditEndingCommand</p>
  
  <pre><code>public ICommand CellEditEndingCommand { get; set; }
  private void CellEditEndingMethod(object obj)
  {
      XDocument xmlPurchases = XDocument.Load(DirectoryPaths.DataDirectory + "Purchases.xml");
      var currentPurchaseInData = (from purchase in xmlPurchases.Element("Purchases").Elements("Purchase")
                                   where Convert.ToInt32(purchase.Attribute("Id").Value) == ServiceLocator.Instance.SelectedPurchase.Id
                                   select purchase).FirstOrDefault();
  
      currentPurchaseInData.SetElementValue("CreditorId", ServiceLocator.Instance.SelectedPurchase.Creditor.Id);
      currentPurchaseInData.SetElementValue("AnimalId", ServiceLocator.Instance.SelectedPurchase.Animal.Id);
      currentPurchaseInData.SetElementValue("QuantityInLitre", ServiceLocator.Instance.SelectedPurchase.Litre);
      currentPurchaseInData.SetElementValue("FAT", ServiceLocator.Instance.SelectedPurchase.FAT);
      currentPurchaseInData.SetElementValue("RatePerLitre", ServiceLocator.Instance.SelectedPurchase.RatePerLitre);
  
      xmlPurchases.Save(DirectoryPaths.DataDirectory + "Purchases.xml");
  }
  </code></pre>
  
  <p>Now If I change any value in DataGridCell and then I hit <kbd>Enter</kbd> CellEditEndingCommand is fired and CellEditEndingMethod is fired. But If I keep a breakpoint inside CellEditEndingMethod and take a look at it, then I can see that Values of any property of SelectedPurchase does not change to new values.</p>
  
  <p>Let me give an example to explain the above line more correctly:</p>
  
  <p>When I keep a breakpoint on any line inside CellEditEndingMethod and take a look at Properties like Litre, FAT etc., these properties values does not change. I mean I expect the property to take new value but it holds old value. Also, In view I can see the new values but in XML file there are still old values.</p>
  
  <p><strong>Update:</strong></p>
  
  <pre><code>Purchases = new ObservableCollection&lt;Purchase&gt;(
      from purchase in XDocument.Load(DirectoryPaths.DataDirectory + "Purchases.xml")
                                .Element("Purchases").Elements("Purchase")
      select new Purchase
      {
          Id = Convert.ToInt32(purchase.Attribute("Id").Value),
          Creditor = (
                          from creditor in XDocument.Load(DirectoryPaths.DataDirectory + "Creditors.xml")
                                                    .Element("Creditors").Elements("Creditor")
                          where creditor.Attribute("Id").Value == purchase.Element("CreditorId").Value
                          select new Creditor
                          {
                              Id = Convert.ToInt32(creditor.Attribute("Id").Value),
                              NameInEnglish = creditor.Element("NameInEnglish").Value,
                              NameInGujarati = creditor.Element("NameInGujarati").Value,
                              Gender = (
                                          from gender in XDocument.Load(DirectoryPaths.DataDirectory + @"Basic\Genders.xml")
                                                                  .Element("Genders").Elements("Gender")
                                          where gender.Attribute("Id").Value == creditor.Element("GenderId").Value
                                          select new Gender
                                          {
                                              Id = Convert.ToInt32(gender.Attribute("Id").Value),
                                              Type = gender.Element("Type").Value,
                                              ImageData = gender.Element("ImageData").Value
                                          }
                                       ).FirstOrDefault(),
                              IsRegisteredMember = creditor.Element("IsRegisteredMember").Value == "Yes" ? true : false,
                              Address = creditor.Element("Address").Value,
                              City = creditor.Element("City").Value,
                              ContactNo1 = creditor.Element("ContactNo1").Value,
                              ContactNo2 = creditor.Element("ContactNo2").Value
                          }
                     ).FirstOrDefault(),
          Animal = (
                      from animal in XDocument.Load(DirectoryPaths.DataDirectory + @"Basic\Animals.xml")
                                              .Element("Animals").Elements("Animal")
                      where animal.Attribute("Id").Value == purchase.Element("AnimalId").Value
                      select new Animal
                      {
                          Id = Convert.ToInt32(animal.Attribute("Id").Value),
                          Type = animal.Element("Type").Value,
                          ImageData = animal.Element("ImageData").Value,
                          Colour = animal.Element("Colour").Value
                      }
                   ).FirstOrDefault(),
          Litre = Convert.ToDouble(purchase.Element("QuantityInLitre").Value),
          FAT = Convert.ToDouble(purchase.Element("FAT").Value),
          RatePerLitre = Convert.ToDouble(purchase.Element("RatePerLitre").Value)
      }
    );
  </code></pre>