Skip to content

Can't resize GridView and DataGrid columns #62

Closed

Description

@meroving

First item of list become dragged when column separator is dragged by mouse in grid header. Width of column isn't changing.

Activity

  1. meroving commented on May 17, 2013

    @meroving
    Author

    Resolves with

    || HitTest4Type<GridViewColumnHeader>(sender, e)

    check at PreviewMouseDown

    DataGridColumnHeader can be tested only for .NET4 version

  2. osicka commented on Jul 10, 2013

    @osicka

    This does not work in a GridView when you drag the column header to reorder its position in the grid. It still drags the first data row.

    The GridViewColumnHeader changes Visibility and the test in HitTest4Type fails.

    I have worked around this by changing HitTest4Type to include a testVisibility parameter.

        private static bool HitTest4Type<T>(object sender, MouseButtonEventArgs e, bool testVisibility = true) where T : UIElement
        {
            var hit = VisualTreeHelper.HitTest((Visual)sender, e.GetPosition((IInputElement)sender));
            if (hit == null)
            {
                return false;
            }
            else
            {
                var element = hit.VisualHit.GetVisualAncestor<T>();
                return element != null && (testVisibility == false || element.Visibility == Visibility.Visible);
            }
        }
    
  3. osicka commented on Jul 10, 2013

    @osicka

    The following also fixes the above issue I spoke about, though it does put a specific test into a generic function.

    return element != null && ((element is GridViewColumnHeader && (element as GridViewColumnHeader).Role == GridViewColumnHeaderRole.Floating) || element.Visibility == Visibility.Visible);

  4. ghost assigned on Aug 6, 2013
  5. added a commit that references this issue on Aug 6, 2013
  6. punker76 commented on Aug 6, 2013

    @punker76
    Owner

    will be fixed with 0.1.3.9

  7. timeichfeld-msa commented on Mar 30, 2021

    @timeichfeld-msa

    Hello,
    This still does not seem to work, I cannot resize headers in a GridControl.
    If I set dd:DragDrop.IsDragSource="False" in the Grid, I get resize of columns back, but can't drag/drop.
    Is there a solution, or a flag I need to set or a special way to define the DD on the grid?

    Please advise.

    Thanks much! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions