Posted 14 December 2018, 6:16 am EST
Hi,
FlexGrid does not provide any resources to achieve such effects however, you can get them by simply writing few lines of code.
In order to have ColumnHeader to be reactive to mouse events, you can use custom CellFactory and override CreateColumnHeaderContent method as follows:
public override void CreateColumnHeaderContent(C1FlexGrid grid, Border bdr, CellRange rng)
{
base.CreateColumnHeaderContent(grid, bdr, rng);
defaultHeaderBrush = bdr.Background;
bdr.MouseEnter += CustomCellFactory_MouseEnter;
bdr.MouseLeave += CustomCellFactory_MouseLeave;
}
And for Drag-Drop effect you can use DraggingColumn event on FlexGrid as follows:
private void FlexGrid_DraggingColumn(object sender, C1.WPF.FlexGrid.CellRangeEventArgs e)
{
if (canvas == null)
{
canvas = new Canvas();
Grid.SetRow(canvas, 0);
Grid.SetRowSpan(canvas, 2);
}
grid.Children.Add(canvas);
//Use TextBlock to create shadow effect
var tb = new TextBlock() { Background = new SolidColorBrush(Color.FromArgb(50, 100, 100, 100)), Text = flexGrid.Columns[e.Column].ColumnName };
tb.Width = (flexGrid.Columns[e.Column].ActualWidth);
tb.Height = (flexGrid.ColumnHeaders.ActualHeight);
var position = Mouse.GetPosition(canvas);
var hitTest = flexGrid.HitTest(position);
var shiftPoint = new Point(position.X - hitTest.Rect.X - flexGrid.RowHeaders.ActualWidth, Mouse.GetPosition(flexGrid).Y);
canvas.Tag = shiftPoint;
tb.Margin = new Thickness(position.X - shiftPoint.X, position.Y - shiftPoint.Y, 0, 0);
canvas.Children.Add(tb);
}
Please refer the attached sample (prj_GroupPanelStyling.zip) for complete implementation of the same.
Thanks and Regards,
Basant
prj_GroupPanelStyling.zip