Beispiel #1
0
        public TransposedItemsSource(IEnumerable source)
        {
            if (source is null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            this.source = new WeakReference(source);
            var type = source.GetElementType();

            this.Properties = TypeDescriptor.GetProperties(type);
            this.rows       = this.Properties.OfType <PropertyDescriptor>()
                              .Select(x => new TransposedRow(this, x))
                              .ToList();

            this.IsReadOnly = this.Properties.OfType <PropertyDescriptor>()
                              .Any(x => !x.IsReadOnly);
            if (source is INotifyCollectionChanged incc)
            {
                CollectionChangedEventManager.AddListener(incc, this);
            }

            foreach (var inpc in this.Source.OfType <INotifyPropertyChanged>())
            {
                PropertyChangedEventManager.AddListener(inpc, this, string.Empty);
            }
        }