I have a WPF Datagrid binded to some properties in my ViewModel
<DataGrid AutoGenerateColumns="False" Name="dataGrid" SelectionMode="Single"
ItemsSource="{Binding ItemList}" SelectedItem="{Binding SelectedItem}">
...
</DataGrid>
When my window load and the Datagrid too, I set the SelectedItem and it binds fine but the row isn’t highlighted. The moment I click a row, the row highlight and the problem is resolved.
How can I set/trigger the highlighting of the SelectedItem in the DataGrid on load/initialization ?
EDIT:
It’s actually selected because I have the little selection cell. It’s just the rendering of the Highlighting that does not trigger.

When using a Model as the DataContext for a WPF Window, the DataGrid’s
SelectionChangedevent doesn’t get called until after the Window is loaded which is why the row is never highlighted and you only see the first row with the partial highlight. There may be a more elegant way, but here’s a work-around.In the Window’s loaded event or the DataGrid’s loaded event, reset the SelectedItem binding:
Here’s a complete working sample.
XAML
Code Behind