Esempio n. 1
0
        public void Update(SortArgument sort_argument)
        {
            // Find comparer
            var comparer = comparers.Find(c => c.Property == sort_argument.Property);

            if (sort_argument.Direction.HasValue) // Sort direction is NOT null, so this is either a new sort property or an old property that must change direction
            {
                if (comparer != null)             // This is an old property that must change direction
                {
                    comparer.Direction = sort_argument.Direction.Value;
                    view.Refresh();
                }
                else // This is a new sort property that must be added
                {
                    Add(factory.Create(sort_argument));
                }
            }
            else // Sort direction is null, so old comparers/sorters must be removed
            {
                if (comparer != null)
                {
                    Remove(comparer);
                }
            }
        }
Esempio n. 2
0
        private static void UpdateHeader(GridViewColumnHeader header, ListSortDirection?direction)
        {
            // Set the sort direction on the header
            SetSortDirection(header, direction);

            // Find the property to report to the command
            string property = GetSortProperty(header.Column);

            if (property == null)
            {
                if (header.Content is string)
                {
                    property = header.Content as string;
                }
                else
                {
                    throw new InvalidOperationException("No sort property or string header defined on column");
                }
            }

            SortArgument sort_argument = new SortArgument(property, direction);

            // Execute the command
            ICommand command = GetSortCommand(header.Column) as ICommand;

            if (command != null && command.CanExecute(sort_argument))
            {
                command.Execute(sort_argument);
            }
        }