In the SfDataGrid, the scroll is not moved to the selected item automatically. Please find below the sample code:
MainWindow.xaml:
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Button Click="Button_Click" Content="New"/>
<sf:SfDataGrid Name="dataGrid" Grid.Row="1"/>
</Grid>
MainWindow.xaml.cs:
public partial class MainWindow : Window
{
ObservableCollection<Person> Persons;
Person mahdi = new Person { Id = 1, Name = "Mahdi" };
public MainWindow()
{
InitializeComponent();
var list = new List<Person>
{
new Person { Id = 2, Name = "John" },
new Person { Id = 2, Name = "John" },
new Person { Id = 2, Name = "John" },
new Person { Id = 2, Name = "John" },
new Person { Id = 2, Name = "John" },
new Person { Id = 2, Name = "John" },
new Person { Id = 2, Name = "John" },
new Person { Id = 2, Name = "John" },
new Person { Id = 2, Name = "John" },
new Person { Id = 2, Name = "John" },
new Person { Id = 2, Name = "John" },
new Person { Id = 2, Name = "John" },
new Person { Id = 2, Name = "John" },
new Person { Id = 2, Name = "John" },
new Person { Id = 2, Name = "John" },
new Person { Id = 2, Name = "John" },
mahdi,
new Person { Id = 2, Name = "John" },
new Person { Id = 2, Name = "John" },
new Person { Id = 2, Name = "John" },
};
Persons = new ObservableCollection<Person>(list);
dataGrid.ItemsSource = Persons;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
dataGrid.SelectedItem = mahdi;
}
}
public class Person
{
public int Id { get; set; }
public string Name { get; set; }
}
Regards,
Mahdi Ehsanifar