views:

46

answers:

1

I would like to set the focus on the first row of a data grid.

This is what I have so far:

Keyboard.Focus(ResultsGrid)
If result.Count > 0 Then
    ResultsGrid.SelectedIndex = 0
End If

This will set the focus to the datagrid, but not the row itself.

A: 

Try this:

yourDataGrid.SelectedItem = yourDataGrid.Items[i];
Taylor Leese
It is complaining that row is null.
Jonathan Allen
ItemContainerGenerator.Status is NotStarted. Is there a way to manually kick it off?
Jonathan Allen
Updated my answer. It's easier than I thought.
Taylor Leese
That has the same problem I had using `SelectedIndex = 0`.
Jonathan Allen
In my application it gave focus to the row and not just the datagrid.
Taylor Leese