Esempio n. 1
0
        /// <summary>
        /// The apply sort.
        /// </summary>
        /// <param name="sortCollection">
        /// The sort collection.
        /// </param>
        public void ApplySort(ListSortDescriptionCollection sortCollection)
        {
            if (this._allowSort)
            {
                bool oldRaise = RaiseListChangedEvents;
                RaiseListChangedEvents = false;
                try
                {
                    var tmp   = new PropertyComparerCollection <T>(sortCollection);
                    var items = new List <T>(this);
                    items.Sort(tmp);
                    int index = 0;
                    foreach (T item in items)
                    {
                        SetItem(index++, item);
                    }

                    this.sorts = tmp;
                }
                finally
                {
                    RaiseListChangedEvents = oldRaise;
                    ResetBindings();
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// The remove sort core.
 /// </summary>
 protected override void RemoveSortCore()
 {
     this.sorts = null;
 }