Skip to content

Commit a03fbfe

Browse files
ES-975464 - Resolve the ReadMe file length issue in this sample repository
1 parent 1670361 commit a03fbfe

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

README.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,20 @@
11
# How to scroll and select the record programmatically in wpf and uwp treegrid?
2-
This example illustrates how to scroll and select the record programmatically in wpf and uwp treegrid
2+
3+
This example illustrates how to scroll and select the record programmatically in WPF TreeGrid and UWP TreeGrid.
4+
5+
You can scroll to the record programmatically using the [ScrollInView](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.SfTreeGrid.html#Syncfusion_UI_Xaml_TreeGrid_SfTreeGrid_ScrollInView_Syncfusion_UI_Xaml_ScrollAxis_RowColumnIndex_) method by passing the row index of the record. You can get the row index of the record using the [ResolveToRowIndex](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeGrid.TreeGridIndexResolver.html#Syncfusion_UI_Xaml_TreeGrid_TreeGridIndexResolver_ResolveToRowIndex_Syncfusion_UI_Xaml_TreeGrid_SfTreeGrid_Syncfusion_UI_Xaml_TreeGrid_TreeNode_) extension method present in `Syncfusion.UI.Xaml.TreeGrid.Helpers`.
6+
7+
You can select the record programmatically by setting the [SelectedItem](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Grid.SfGridBase.html#Syncfusion_UI_Xaml_Grid_SfGridBase_SelectedItem) property in `TreeGrid`.
8+
9+
``` c#
10+
private void Treegrid_Loaded(object sender, System.Windows.RoutedEventArgs e)
11+
{
12+
var selectedItem = (this.treegrid.DataContext as ViewModel).SelectedItem;
13+
var rowindex = this.treegrid.ResolveToRowIndex(selectedItem);
14+
var columnindex = this.treegrid.ResolveToStartColumnIndex();
15+
//Make the row in to available on the view.
16+
this.treegrid.ScrollInView(new RowColumnIndex(rowindex, columnindex));
17+
//Set the SelectedItem in SfTreeGrid.
18+
this.treegrid.SelectedItem = selectedItem;
19+
}
20+
```

0 commit comments

Comments
 (0)