public DataGridCollectionViewSourceBase() { m_itemProperties = new ObservableCollection <DataGridItemPropertyBase>(); m_itemProperties.CollectionChanged += new NotifyCollectionChangedEventHandler(this.ForwardedCollection_CollectionChanged); m_dataGridDetailDescriptions = new DataGridDetailDescriptionCollection(); m_dataGridDetailDescriptions.CollectionChanged += new NotifyCollectionChangedEventHandler(this.ForwardedCollection_CollectionChanged); // We force a culture because it is the only way to be // notified when the Culture changes in order to launch our own // ApplyExtraPropertiesToView (because the implentation of ApplyPropertiesToView is not virtual!) // // See CollectionViewSource.ApplyPropertiesToView in reflector for a better understanding. this.Culture = CultureInfo.InvariantCulture; }
protected DataGridDetailDescription() { m_itemProperties = new DataGridItemPropertyCollection(); m_detailDescriptions = new DataGridDetailDescriptionCollection(); m_defaultPropertyDescriptions = new PropertyDescriptionRouteDictionary(); m_groupDescriptions = new GroupDescriptionCollection(); m_sortDescriptions = new DataGridSortDescriptionCollection(); this.AutoCreateDetailDescriptions = true; this.AutoCreateItemProperties = true; this.DefaultCalculateDistinctValues = true; CollectionChangedEventManager.AddListener(m_itemProperties, this); InitializeItemPropertyEventManager.AddListener(m_itemProperties, this); CollectionChangedEventManager.AddListener(m_detailDescriptions, this); }
protected DataGridDetailDescription() { m_detailDescriptions = new DataGridDetailDescriptionCollection(); m_detailDescriptions.CollectionChanged += this.OnDetailDescriptionsCollectionChanged; m_itemProperties = new DataGridItemPropertyCollection(); m_itemProperties.CollectionChanged += this.OnItemPropertiesCollectionChanged; m_groupDescriptions = new GroupDescriptionCollection(); m_sortDescriptions = new DataGridSortDescriptionCollection(); m_statFunctions = new StatFunctionCollection(); m_autoFilterValues = new ReadOnlyDictionary <string, IList>(); m_autoFilteredItems = new ObservableCollection <DataGridItemPropertyBase>(); m_registeredFieldNamesToAutoFilterValues = new Dictionary <string, INotifyCollectionChanged>(); m_registeredAutoFilterValuesToFieldNames = new Dictionary <INotifyCollectionChanged, string>(); this.AutoCreateDetailDescriptions = true; this.AutoCreateItemProperties = true; this.DefaultCalculateDistinctValues = true; }
internal virtual void ApplyExtraPropertiesToView(DataGridCollectionViewBase currentView) { DataGridItemPropertyCollection currentViewItemProperties = currentView.ItemProperties; int count = m_itemProperties.Count; for (int i = 0; i < count; i++) { DataGridItemPropertyBase itemProperty = m_itemProperties[i]; int index = currentViewItemProperties.IndexOf(itemProperty.Name); if (index == -1) { currentViewItemProperties.Add(itemProperty); } else { currentViewItemProperties[index] = itemProperty; } } count = currentView.ItemProperties.Count; bool defaultCalculateDistinctValues = this.DefaultCalculateDistinctValues; for (int i = 0; i < count; i++) { DataGridItemPropertyBase dataGridItemProperty = currentView.ItemProperties[i]; // Set default value for CalculateDistinctValues if not explicitly set if (!dataGridItemProperty.IsCalculateDistinctValuesInitialized) { dataGridItemProperty.CalculateDistinctValues = defaultCalculateDistinctValues; } } count = m_dataGridDetailDescriptions.Count; bool autoCreateForeignKeyDescriptions = this.AutoCreateForeignKeyDescriptions; DataGridDetailDescriptionCollection currentViewDetailDescriptions = currentView.DetailDescriptions; for (int i = 0; i < count; i++) { DataGridDetailDescription detailDescription = m_dataGridDetailDescriptions[i]; int index = currentViewDetailDescriptions.IndexOf(detailDescription.RelationName); if (index == -1) { currentViewDetailDescriptions.Add(detailDescription); } else { currentViewDetailDescriptions[index] = detailDescription; } // We assume we want to auto-create ForeignKeyDescriptions for DetailDescriptions // if this.AutoCreateForeignKeyDescriptions is true and it was auto-created if (detailDescription.IsAutoCreated) { detailDescription.AutoCreateForeignKeyDescriptions = autoCreateForeignKeyDescriptions; } } currentView.AutoFilterMode = this.AutoFilterMode; currentView.DistinctValuesConstraint = this.DistinctValuesConstraint; currentView.DistinctValuesUpdateMode = this.DistinctValuesUpdateMode; currentView.FilterCriteriaMode = this.FilterCriteriaMode; }