protected internal override void Initialize(DataGridCollectionViewBase parentCollectionView) { base.Initialize(parentCollectionView); if (this.PropertyDescriptor != null) { return; } string relationName = this.RelationName; if (String.IsNullOrEmpty(relationName) == true) { throw new InvalidOperationException("An attempt was made to initialize a PropertyDetailDescription whose Name property has not been set."); } var enumeration = parentCollectionView as IEnumerable; if (enumeration != null) { // Try to get it from the first item in the DataGridCollectionView var firstItem = ItemsSourceHelper.GetFirstItemByEnumerable(enumeration); if (firstItem != null) { var propertyDescriptor = this.GetPropertyDescriptorFromFirstItem(firstItem); if (propertyDescriptor != null) { this.PropertyDescriptor = propertyDescriptor; return; } } } // If the list is empty, check if the SourceCollection is ITypedList var typedList = parentCollectionView.SourceCollection as ITypedList; if (typedList != null) { var propertyDescriptor = this.GetPropertyDescriptorFromITypedList(typedList); if (propertyDescriptor != null) { this.PropertyDescriptor = propertyDescriptor; return; } } throw new InvalidOperationException("An attempt was made to initialize a PropertyDetailDescription whose data source does not contain a property that corresponds to the specified relation name."); }
protected internal override void Initialize(DataGridCollectionViewBase parentCollectionView) { base.Initialize(parentCollectionView); if (this.PropertyDescriptor != null) { return; } string relationName = this.RelationName; if (String.IsNullOrEmpty(relationName) == true) { throw new InvalidOperationException("An attempt was made to initialize a PropertyDetailDescription whose Name property has not been set."); } foreach (DataGridDetailDescription detailDescription in parentCollectionView.DetailDescriptions.DefaultDetailDescriptions) { PropertyDetailDescription propertyDetailDescription = detailDescription as PropertyDetailDescription; if (propertyDetailDescription != null) { if (propertyDetailDescription.RelationName == relationName) { this.PropertyDescriptor = propertyDetailDescription.PropertyDescriptor; return; } } } // The DetailDescription for RelationName was not found in DefaultDetailDescription // and may not have the PropertyDetailDescriptionAttribute if (this.PropertyDescriptor == null) { PropertyDescriptor relationDescriptor = null; IEnumerable enumeration = parentCollectionView as IEnumerable; if (enumeration != null) { // Try to get it from the first item in the DataGridCollectionView object firstItem = ItemsSourceHelper.GetFirstItemByEnumerable(enumeration); if (firstItem != null) { relationDescriptor = this.GetPropertyDescriptorFromFirstItem(firstItem); if (relationDescriptor != null) { this.PropertyDescriptor = relationDescriptor; return; } } } // If the list is empty, check if the SourceCollection is ITypedList ITypedList iTypedList = parentCollectionView.SourceCollection as ITypedList; if (iTypedList != null) { relationDescriptor = this.GetPropertyDescriptorFromITypedList(iTypedList); if (relationDescriptor != null) { this.PropertyDescriptor = relationDescriptor; return; } } } throw new InvalidOperationException("An attempt was made to initialize a PropertyDetailDescription whose data source does not contain a property that corresponds to the specified relation name."); }