Beispiel #1
0
        private void OnItemCollectionSourceChangedSafe(NotifyCollectionChangedEventArgs e)
        {
            VerifySafe();

            if (e.Action == NotifyCollectionChangedAction.Move)
            {
            }
            else if (e.Action == NotifyCollectionChangedAction.Reset)
            {
                if (SupportsIndex)
                {
                    if (MultipleSelection)
                    {
                        CurrentSelectionCollection.UpdateIndicesSources();
                    }

                    if (CurrentSelectedIndex != -1)
                    {
                        var source = GetSource(CurrentSelectedIndex);

                        Sync(source != null ? CurrentSelection.WithSource(source) : CurrentSelection.WithIndex(-1));
                    }
                }
            }
            else
            {
                if (e.NewItems != null)
                {
                    foreach (var source in e.NewItems)
                    {
                        if (IsSourceSelected(source))
                        {
                            SelectSourceSafe(source);
                        }
                    }
                }

                if (e.OldItems != null)
                {
                    foreach (var source in e.OldItems)
                    {
                        if (IsSourceInSelection(source))
                        {
                            UnselectSourceSafe(source);
                        }
                    }
                }
            }

            SyncIndex(false);
            EnsureSelection();
        }