System.Windows.Data.StandardCollectionViewGroup.AddItem C# (CSharp) Méthode

AddItem() private méthode

private AddItem ( object item, bool allowSorting ) : void
item object
allowSorting bool
Résultat void
		internal void AddItem (object item, bool allowSorting)
		{
			int index = ProtectedItems.Count;
			if (allowSorting && Sorters.Count > 0 && !(item is CollectionViewGroup)) {
				var comparer = new PropertyComparer (Sorters);
				for (int i = 0; i < ProtectedItems.Count; i++) {
					if (comparer.Compare (item, ProtectedItems [i]) < 0) {
						index = i;
						break;
					}
				}
			}

			ProtectedItems.Insert (index, item);
			if (!(item is StandardCollectionViewGroup))
				IncrementCount ();
		}

Usage Example

		void AddInSubtree (StandardCollectionViewGroup group, object item, CultureInfo culture, IList<GroupDescription> descriptions, bool allowSorting)
		{
			int depth = group.Depth;
			if (group.IsBottomLevel) {
				group.AddItem (item, allowSorting);
				CollectionChanged.Raise (this, new NotifyCollectionChangedEventArgs (NotifyCollectionChangedAction.Add, item, IndexOfSubtree (item)));
			} else {
				var desc = descriptions [group.Depth];
				var groupNames = desc.GroupNameFromItem (item, group.Depth, culture);
				if (groupNames is IList) {
					foreach (var name in (IList) groupNames)
						AddInSubtree (group, item, culture, descriptions, allowSorting, name);
				} else {
					AddInSubtree (group, item, culture, descriptions, allowSorting, groupNames);
				}
			}
		}
All Usage Examples Of System.Windows.Data.StandardCollectionViewGroup::AddItem