internal void HandleGroupFlyoutDescriptorContentTap(object sender, EventArgs e)
        {
            var descriptor = (sender as FrameworkElement).DataContext as GroupDescriptorBase;

            if (descriptor == null)
            {
                Debug.Assert(false, "Invalid HandleGroupFlyoutHeaderClosed event sender");
                return;
            }

            // raise the FlyoutGroupHeaderTap command
            var context = new FlyoutGroupHeaderTapContext()
            {
                Action     = DataGridFlyoutGroupHeaderTapAction.ChangeSortOrder,
                Descriptor = descriptor
            };

            this.Owner.commandService.ExecuteCommand(CommandId.FlyoutGroupHeaderTap, context);
        }
        internal void HandleGroupFlyoutHeaderClosed(object sender, EventArgs e)
        {
            var descriptor = (sender as FrameworkElement).DataContext as GroupDescriptorBase;

            if (descriptor == null)
            {
                Debug.Assert(false, "Invalid HandleGroupFlyoutHeaderClosed event sender");
                return;
            }

            if (descriptor is CollectionViewGroupDescriptor)
            {
                Debug.Assert(false, "CollectionViewGroupDescriptor cannot be removed by the user.");
                return;
            }

            int previousCount = this.Owner.GroupDescriptors.Count;

            // raise the FlyoutGroupHeaderTap command and see whether the descriptor count has changed
            var context = new FlyoutGroupHeaderTapContext()
            {
                Action     = DataGridFlyoutGroupHeaderTapAction.RemoveDescriptor,
                Descriptor = descriptor
            };

            this.Owner.commandService.ExecuteCommand(CommandId.FlyoutGroupHeaderTap, context);

            if (previousCount == this.Owner.GroupDescriptors.Count)
            {
                // the user has prevented the removal of the associated descriptor, so do nothing
                return;
            }

            if (this.Owner.GroupDescriptors.Count > 0)
            {
                this.groupFlyoutContent.ClearUI();
                this.groupFlyoutContent.PrepareUI();
            }
            else
            {
                this.groupFlyout.IsOpen = false;
            }
        }