0

I have a WPF DataDrid where I'm using a combination of row selection and cell selection.

That is - I want full row select and an indication of the currently selected simultaneously. That is working fine if I use SelectionUnit=FullRow and SelectionMode=Single and combined with a thicker cell border this looks pretty good.

The problem is that when the DataGrid loses focus only the row selection stays visible, the CurrentCell property is reset and there is no way for the user to identify which cell is selected. This also happens if the user is interacting with the content in the RowDetails panel.

Is there any way to change the behavior of the current cell so that it shows the SelectedCell even when not focused?

Patrik B
  • 151
  • 1
  • 13
  • Look at this question: http://stackoverflow.com/questions/7998112/datagrids-selected-row-color-when-inactive Hope, it'll help. – Vladimir Mar 27 '13 at 08:37
  • That question applies to the Inactive color of the row. I want to keep the selection rectangle of the current cell. I guess that one part of the problem is that CurrentCell becomes null as soon as the control becomes inactive. – Patrik B Mar 27 '13 at 08:52

1 Answers1

0

Do not use the CurrentCell to track the selected row. Use the property SelectedItem instead.

Something like this:

<DataGrid ItemsSource="{Binding MyItems}" SelectedItem="{Binding MySelectedItem}">
  ...
</DataGrid>
Heiner
  • 1,869
  • 1
  • 19
  • 33