title: How to get row by index in wpf datagrid
body: <p>I have a datagrid and when I load data on this data grid I want to focus on selected row. But I don't get row by index. </p>
  
  <pre><code>if (gridAppointment.SelectedIndex &gt;= 0)
  {
     gridAppointment.ScrollIntoView(gridAppointment.Items[gridAppointment.SelectedIndex]);
     DataGridRow row = (DataGridRow)gridAppointment.ItemContainerGenerator.ContainerFromIndex(
           gridAppointment.SelectedIndex);
     if (row != null)
         row.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));                                               
   }
  </code></pre>