コード例 #1
0
        internal static bool RaiseGroupByChanging(
            GridViewTemplate template,
            GroupDescriptor groupDescription,
            NotifyCollectionChangedAction action)
        {
            GridGroupByExpression fromDescriptor = GridGroupByExpression.CreateFromDescriptor(groupDescription);
            GridViewCollectionChangingEventArgs args;

            if (action == NotifyCollectionChangedAction.Add || action == NotifyCollectionChangedAction.ItemChanged || action == NotifyCollectionChangedAction.Remove)
            {
                args = new GridViewCollectionChangingEventArgs(template, action, (object)fromDescriptor, 0, 0);
            }
            else
            {
                if (action != NotifyCollectionChangedAction.Batch)
                {
                    throw new ArgumentException("Invalid action");
                }
                IList newItems = (IList) new List <GridGroupByExpression>();
                newItems.Add((object)fromDescriptor);
                args = new GridViewCollectionChangingEventArgs(template, action, newItems, (IList)template.GroupDescriptors, 0, 0, (PropertyChangingEventArgsEx)null);
            }
            template.EventDispatcher.RaiseEvent <GridViewCollectionChangingEventArgs>(EventDispatcher.GroupByChanging, (object)template, args);
            if (!args.Cancel)
            {
                template.EventDispatcher.SuspendEvent(EventDispatcher.GroupByChanging);
                template.EventDispatcher.SuspendEvent(EventDispatcher.GroupByChanged);
                template.MasterTemplate.SynchronizationService.BeginDispatch();
            }
            return(args.Cancel);
        }