public async void LoadState(IDataContext state) { TrackingCollection trackingCollection = state.GetData(StateConstant); if (trackingCollection == null) { return; } IList <IEntityStateEntry> changes = trackingCollection.GetChanges(); await _initializedTask; _trackingCollection.UpdateStates(changes); foreach (IEntityStateEntry change in changes) { var oldOrder = change.Entity as OrderModel; if (oldOrder == null) { _trackingCollection.UpdateState(change); } else { OrderModel currentOrder = GridViewModel.OriginalItemsSource.FirstOrDefault(model => model.Id == oldOrder.Id); switch (change.State) { case EntityState.Added: GridViewModel.OriginalItemsSource.Add(oldOrder); break; case EntityState.Modified: if (currentOrder != null) { GridViewModel.OriginalItemsSource.Remove(currentOrder); } GridViewModel.OriginalItemsSource.Add(oldOrder); break; case EntityState.Deleted: if (currentOrder != null) { GridViewModel.OriginalItemsSource.Remove(currentOrder); } break; } } } this.OnPropertyChanged(() => v => v.HasChanges); }