Can't resize GridView and DataGrid columns
meroving opened this issue · 5 comments
First item of list become dragged when column separator is dragged by mouse in grid header. Width of column isn't changing.
Resolves with
|| HitTest4Type<GridViewColumnHeader>(sender, e)
check at PreviewMouseDown
DataGridColumnHeader can be tested only for .NET4 version
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);
}
}
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);
will be fixed with 0.1.3.9
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! :)