Пример #1
0
        public ProxyValueCollection(ObservableCollection <T> realCollection)
            : base(Enumerable.Range(0, realCollection.Count).Select(i => new ProxiedValue <T>(i, realCollection)))
        {
            m_realCollection = realCollection;
            m_realCollectionCollectionChangedEvent = new WeakEvent <NotifyCollectionChangedEventHandler>(m_realCollection, nameof(m_realCollection.CollectionChanged));

            m_realCollectionCollectionChangedEvent += OnRealCollectionOnCollectionChanged;
            CollectionChanged += OnBoxedValueCollectionChanged;
        }
Пример #2
0
        private void OnBoxedValueCollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
        {
            switch (args.Action)
            {
            case NotifyCollectionChangedAction.Remove:
                m_realCollectionCollectionChangedEvent -= OnRealCollectionOnCollectionChanged;
                m_realCollection.RemoveAt(args.OldStartingIndex);
                m_realCollectionCollectionChangedEvent += OnRealCollectionOnCollectionChanged;
                break;

            case NotifyCollectionChangedAction.Replace:
                break;

            default:
            case NotifyCollectionChangedAction.Add:
                throw new NotImplementedException();

            case NotifyCollectionChangedAction.Move:
            case NotifyCollectionChangedAction.Reset:
                throw new ArgumentOutOfRangeException();
            }
        }