private void Button_Click(object sender, RoutedEventArgs e)
{
var collection = (this.dataGrid.View as PagedCollectionView).GetInternalList();
int i = 0;
foreach (var rec in collection)
{
var value = (rec as OrderInfo).RecordID;
if ((int)value == 1119)//given RecordID
{
int index = i / this.sfDataPager.PageSize;
// Move to given record page
this.sfDataPager.PageIndex = index;
// Select the given record
this.dataGrid.SelectedIndex = i % this.sfDataPager.PageSize;
var rowindex = this.dataGrid.ResolveToRowIndex(this.dataGrid.SelectedIndex);
var visualcontainer = this.dataGrid.GetVisualContainer();
visualcontainer.ScrollRows.ScrollInView(rowindex);
break;
}
i++;
}
} |
private async void DataGrid_Loaded(object sender, RoutedEventArgs e)
{
var collection = (this.dataGrid.View as PagedCollectionView).GetInternalList();
int i = 0;
foreach (var rec in collection)
{
var value = (rec as OrderInfo).RecordID;
if ((int)value == 1119)
{
int index = i / this.sfDataPager.PageSize;
this.sfDataPager.PageIndex = index;
this.dataGrid.SelectedIndex = i % this.sfDataPager.PageSize;
var rowindex = this.dataGrid.ResolveToRowIndex(this.dataGrid.SelectedIndex);
await Task.Delay(5);
dataGrid.ScrollInView(new Syncfusion.UI.Xaml.ScrollAxis.RowColumnIndex(rowindex, 1));
break;
}
i++;
}
}
private void Button_Click(object sender, RoutedEventArgs e)
{
this.Frame.Navigate(typeof(MainPage));
} |
And then created a method:this.dataGrid.Loaded += dataGrid_Loaded;
private void dataGrid_Loaded(object sender, RoutedEventArgs e)
var collection = (this.dataGrid.View asPagedCollectionView).GetInternalList();
sfDataPager.Source = myDataList;
await Task.Delay(25000);
protected override void OnNavigatedTo(NavigationEventArgs e)
{
ViewModel vm = new ViewModel();
sfDataPager.Source = vm.OrderList;
this.dataGrid.Loaded += DataGrid_Loaded;
} |