Esempio n. 1
0
        protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
        {
            bool isMouseCaptured = this.IsMouseCaptured;
            bool isPressed       = this.IsPressed;

            if (m_dragSourceManager != null)
            {
                m_dragSourceManager.ProcessMouseLeftButtonUp(e);
            }

            if (isMouseCaptured)
            {
                bool click = isPressed;

                if (click)
                {
                    // DataGridCollectionView always return true for CanSort
                    bool allowSort = true;

                    // Use the ParentDataGridContext to be sure to get a
                    // DataGridContext of the correct detail level since
                    // all the HierarchicalGroupByItem will share the same DataGridContext
                    // which is the one of the level where the HierarchicalGroupByControl
                    // is located
                    DataGridContext dataGridContext = this.ParentDataGridContext;

                    if ((dataGridContext != null) && (dataGridContext.SourceDetailConfiguration == null))
                    {
                        allowSort = dataGridContext.Items.CanSort;
                    }

                    if (allowSort)
                    {
                        ColumnCollection      columns   = this.ParentColumns;
                        GroupLevelDescription groupInfo = this.Content as GroupLevelDescription;

                        Debug.Assert((columns != null) && (groupInfo != null));

                        if ((columns != null) && (groupInfo != null))
                        {
                            ColumnBase column = columns[groupInfo.FieldName];

                            if ((column != null) && (column.AllowSort))
                            {
                                bool shiftUnpressed = ((Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.Shift);

                                var toggleColumnSort = new HierarchicalGroupByItemToggleColumnSortCommand(this);

                                if (toggleColumnSort.CanExecute(column, shiftUnpressed))
                                {
                                    toggleColumnSort.Execute(column, shiftUnpressed);
                                }

                                e.Handled = true;
                            }
                        }
                    }
                }
            }

            base.OnMouseLeftButtonUp(e);
        }
    protected override void OnMouseLeftButtonUp( MouseButtonEventArgs e )
    {
      bool isMouseCaptured = this.IsMouseCaptured;
      bool isPressed = this.IsPressed;

      if( m_dragSourceManager != null )
        m_dragSourceManager.ProcessMouseLeftButtonUp( e );

      if( isMouseCaptured )
      {
        bool click = isPressed;

        if( click )
        {
          // DataGridCollectionView always return true for CanSort
          bool allowSort = true;

          // Use the ParentDataGridContext to be sure to get a
          // DataGridContext of the correct detail level since
          // all the HierarchicalGroupByItem will share the same DataGridContext
          // which is the one of the level where the HierarchicalGroupByControl
          // is located
          DataGridContext dataGridContext = this.ParentDataGridContext;

          if( ( dataGridContext != null ) && ( dataGridContext.SourceDetailConfiguration == null ) )
          {
            allowSort = dataGridContext.Items.CanSort;
          }

          if( allowSort )
          {
            ColumnCollection columns = this.ParentColumns;
            GroupLevelDescription groupInfo = this.Content as GroupLevelDescription;

            Debug.Assert( ( columns != null ) && ( groupInfo != null ) );

            if( ( columns != null ) && ( groupInfo != null ) )
            {
              ColumnBase column = columns[ groupInfo.FieldName ];

              if( ( column != null ) && ( column.AllowSort ) )
              {
                bool shiftUnpressed = ( ( Keyboard.Modifiers & ModifierKeys.Shift ) != ModifierKeys.Shift );

                var toggleColumnSort = new HierarchicalGroupByItemToggleColumnSortCommand( this );

                if( toggleColumnSort.CanExecute( column, shiftUnpressed ) )
                {
                  toggleColumnSort.Execute( column, shiftUnpressed );
                }

                e.Handled = true;
              }
            }
          }
        }
      }

      base.OnMouseLeftButtonUp( e );
    }