I am binding a collection to a grid with the ActiveDataItem bound to a property on my ViewModel. When the view first comes up I want the first item selected by default. I'm accomplishing this with the following code in the FieldLayoutInitialized event handler.
grid.Records[0].IsActive = true;
grid.Records[0].IsSelected = true;
grid.ActiveRecord = grid.Records[0];
This seems to select the row because my property that is bound to the ActiveDataItem is getting updated. However, the first row in the grid isn't actually highlighted. What am I doing wrong? It also seems odd that I need all three of those lines of code for anything to happen. Just setting the first row IsActive = true doesn't do anything.
Using the Loaded event worked, thank you!
It could be that it is too early for the records to be generated. Have you tried calling these in the Loaded event of the XamDataGrid, or at least in the InitializeRecord?