void ITrackedList_CollectionChanged(object sender, TrackedListChangedEventArgs <TId, TTrackedModel> e)
 {
     if (e.ChangeEvent == TrackedListChangeEvent.Select)
     {
         // Update selection on grid control.
         var trackedListSelectedItem = e.NewItems?.FirstOrDefault();
         if (trackedListSelectedItem == null)
         {
             if (this.SelectedItem != null)
             {
                 this.SelectedItem = null;
             }
         }
         else
         {
             if (this.SelectedItem == null || !this.SelectedItem.Id.Equals(trackedListSelectedItem.Id))
             {
                 var newStartingIndex = e.NewStartingIndex;
                 if (newStartingIndex > 0 && newStartingIndex < this.Items.Count)
                 {
                     this.SelectedItem = this.Items[newStartingIndex];
                 }
             }
         }
     }
     else
     {
         // Update observable collection, that is bound to grid, based on changes to shared data service tracked list.
         var notifyCollectionChangedEventArgs = e.ConvertToNotifyCollectionChangedEventArgs();
         if (notifyCollectionChangedEventArgs != null)
         {
             TrackedListUtilities.ReplayChanges <TTrackedModel, TTrackedModel>(
                 notifyCollectionChangedEventArgs,
                 this.Items,
                 (sourceModel, targetModel) => sourceModel.Id.Equals(targetModel.Id),
                 tm => tm);
         }
     }
 }
        private void ObservableCollection_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (e.OldItems != null)
            {
                MultipleItemsRemovedFromCollection(e.OldItems.Cast <TTrackedModel>());
            }

            if (e.NewItems != null)
            {
                MultipleItemsAddedToCollection(e.NewItems.Cast <TTrackedModel>());
            }

            // Update shared data service.
            TrackedListUtilities.ReplayChanges <TTrackedModel, TTrackedModel>(
                e,
                trackedList,
                (sourceModel, targetModel) => sourceModel.Id.Equals(targetModel.Id),
                vm => vm);

            OnCollectionChanged(e);
            this.CollectionChanged?.Invoke();
        }