Xceed DataGrid WPF Mouse Single Click Event

Have you been trying to find the event that fires when you select a single record from the Xceed DataGrid? It doesn’t exist! You can play around with the MouseDown event a bit, but it doesn’t quite do the trick since this fires when the scrollbar is pressed and has some other weird side effects. Other Events are worse.

Our developers (including myself) were banging our head up against the wall with this problem until we found a pretty reliable way of capturing when the user single clicks on a record on the DataGrid. I cannot answer why most WPF controls don’t have the Mouse Single Click Event, but this functionality should have been better exposed since it has so many useful applications. This one is a gem, so please comment if you found this article useful in your project.

Enjoy!

Private Sub myDataGridControl_PropertyChanged _
(ByVal sender As Object, _
ByVal e As System.ComponentModel.PropertyChangedEventArgs)
Handles myDataGridControl.PropertyChanged

    If e.PropertyName = "GlobalSelectedItems" Then
        'myDataGridControl.SelectedItem was clicked!
    End If

End Sub
TAGS: , ,