public void MoveItemUp(ServersModel server)
        {
            int currentIndex = Servers.IndexOf(server);

            if (currentIndex <= 0)
            {
                return;
            }

            Servers.Move(currentIndex, currentIndex - 1);
        }
        /// <summary>
        /// Сортировка коллекции BindableCollection
        /// </summary>
        /// <typeparam name="T">Коллекция BindableCollection</typeparam>
        /// <param name="collection">Коллекция</param>
        /// <param name="comparison">Выражение сравнения</param>
        public static void Sort <T>(this BindableCollection <T> collection, Comparison <T> comparison)
        {
            var sortableList = new List <T>(collection);

            sortableList.Sort(comparison);
            sortableList.Reverse();

            for (int i = 0; i < sortableList.Count; i++)
            {
                collection.Move(collection.IndexOf(sortableList[i]), i);
            }
        }
Пример #3
0
        public static void Sort <T>(this BindableCollection <T> collection, Func <T, object> order)
        {
            List <T> ordered = collection.OrderBy(order).ToList();

            for (int index = 0; index < ordered.Count; index++)
            {
                T dataBindingConditionViewModel = ordered[index];
                if (collection.IndexOf(dataBindingConditionViewModel) != index)
                {
                    collection.Move(collection.IndexOf(dataBindingConditionViewModel), index);
                }
            }
        }
        public ReportBookViewModel()
        {
            BookGenres = DictBookGenreServices.GetAll();
            DictBookGenre filterAll = new DictBookGenre()
            {
                BookGenreId = 0, Name = "All"
            };

            BookGenres.Add(filterAll);
            BookGenres.Move(BookGenres.IndexOf(filterAll), 0);
            numberOfBooks = BookServices.NumberOfBooks(null, new DictBookGenre()
            {
                BookGenreId = 0, Name = null
            });
            NumberOfBorrowsPerTitle = BorrowServices.NumberOfBorrowsPerTitle(SelectedTitle, SelectedBookGenre, FromDate, ToDate, ActualPage, PageSize);
        }