Home WPF DataGrid - How detect if full row is selected?
 I have DataGrid in my WPF application, and I want to run a function in the SelectedCellsChanged event, but only if the row is not fully selected, which happens if the user clicks at the header of the row. My table has only one column. I've tried the following code and always the value of rowContainer.IsSelected is false. How can I do this? Private Sub DataGridEx_SelectionChanged(sender As Object, e As SelectionChangedEventArgs) Handles Me.SelectionChanged If SelectedCells.Count <> 1 Then Exit Sub End If If Not SelectedCells.First.Item.ToString.Contains("NewItemPlaceholder") Then Me.TheDispatcher.BeginInvoke( Sub() Dim cell = SelectedCells.First Dim index = Items.IndexOf(cell.Item) + 1 Dim rowContainer As DataGridRow = ItemContainerGenerator.ContainerFromIndex(index) If rowContainer IsNot Nothing Then If Not rowContainer.IsSelected Then ' run a function here End If End If End Sub, DispatcherPriority.Input) End If End Sub