-1

I have a WPF-Datagrid with a Number of columns and I use the PreviewMouseDown Event to do some custom handling, like setting the background colour of the Columns. That works just fine. My trouble comes from the fact that the PreviewMouseDown is also fired when somebody tries to resize the Columns. The "<->" Cursor is shown, but the event is send to PreviewMouseDown and I have found no way to distinguish between a normal click and resizing.

Note: I am using Caliburn Micros Events. They should just forward specific events to methods, so there is probably no interference. XAML:

 <DataGrid x:Name="excelDataTable_ExcelData"  IsReadOnly="True" CanUserReorderColumns="False" CanUserSortColumns="False" cal:Message.Attach="[Event PreviewMouseDown] = [Action HeaderSelected($EventArgs)]">

</DataGrid>

C# code:

 public void HeaderSelected(System.Windows.Input.MouseButtonEventArgs e)
{
// do stuff
}

1 Answer 1

0

The answer is in your question only, you can check for the 'Cursors' type in Preview event, if its not what you want say e.handled = true.

2
  • THank you very much. That actually works. Unfortunately, it got reset when I have to change the contents of the DataGrid. Which happens quite often :( Feb 3, 2014 at 18:17
  • I down voted your one sentence answer because it only has one sentence in it and falls far below the usual standard for answers on this website.
    – Sheridan
    Feb 4, 2014 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.