我有一個數據網格,當我在這個數據網格上加載數據時,我想關注選定的行。但是我沒有通過索引獲得排名。如何在wpf數據網格中按索引獲取行
if (gridAppointment.SelectedIndex >= 0)
{
gridAppointment.ScrollIntoView(gridAppointment.Items[gridAppointment.SelectedIndex]);
DataGridRow row = (DataGridRow)gridAppointment.ItemContainerGenerator.ContainerFromIndex(
gridAppointment.SelectedIndex);
if (row != null)
row.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
}
那麼使用SelectedItem呢? –