Datagrid column header mousemove event
-
Tuesday, May 15, 2012 2:39 PM
Hi,
i am trying to do grouping in datagrid , with column header drag and drop. for that i am writing MouseMove event. my problem is my mouse move event always gives me e.LeftButton as Released though i clicked it. if anoybody has sample for the above grouping it's also welcome and naturally the solution for this mouse move problem.
here is my mouse move code.
private void dgData_MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { Point currentPosition = e.GetPosition(dgData); DependencyObject dep = (DependencyObject)e.OriginalSource; while ((dep != null) && !(dep is DataGridCell) && !(dep is DataGridColumnHeader)) { dep = VisualTreeHelper.GetParent(dep); } if (dep == null) return; if (dep is DataGridColumnHeader) { DataGridColumnHeader columnHeader = dep as DataGridColumnHeader; if (columnHeader != null) { DragDropEffects finalDropEffect = DragDrop.DoDragDrop(columnHeader, columnHeader.Content, DragDropEffects.Move); } } } }
Thanks & Regards dhampall
All Replies
-
Thursday, May 17, 2012 6:17 AMModerator
Hi dhampall_79,
Try to use PreviewMouseMove event insthead of MouseMove(if nessary, you could also add a PreviewMouseLeftButtonDown), and then I thing you could complete the Drag.Drop behavior,
Best regards,
Sheldon _Xiao[MSFT]
MSDN Community Support | Feedback to us
Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marked As Answer by Sheldon _XiaoModerator Thursday, May 24, 2012 7:01 AM
-
Thursday, May 24, 2012 7:01 AMModerator
Hi dhampall_79,
I am marking your issue as "Answered", if you have new findings about your issue, please let me know.
Best regards,Sheldon _Xiao[MSFT]
MSDN Community Support | Feedback to us
Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.

