I have a datagrid/gridview. I\'m populating the grid with 10 rows initially. On a button click every time,I\'m keeping on adding 10 rows to the datagrid/gridview. Now I want
Try this, it's work for me
public static void ItemSetFocus(DataGrid Dg, int SelIndex)
{
if (Dg.Items.Count >= 1 && SelIndex < Dg.Items.Count)
{
Dg.ScrollIntoView(Dg.Items.GetItemAt(SelIndex));
Dg.SelectionMode = DataGridSelectionMode.Single;
Dg.SelectionUnit = DataGridSelectionUnit.FullRow;
Dg.SelectedIndex = SelIndex;
DataGridRow row = (DataGridRow)Dg.ItemContainerGenerator.ContainerFromIndex(SelIndex);
row.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
}
}