private void ProductDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems != null && e.AddedItems.Count > 0) { ProductDataGrid.ScrollIntoView(e.AddedItems[0]); } }
private void Page_Loaded(object sender, RoutedEventArgs e) { using (SmallBusinessDBEntities context = new SmallBusinessDBEntities()) { try { productLict = context.Products.ToList(); ProductDataGrid.ItemsSource = productLict; ProductDataGrid.Focus(); ProductDataGrid.SelectedIndex = 0; }//try catch (Exception ex) { MessageBox.Show(ex.Message); } //catch } //using }