This example illustrates to bind the SelectedItem property from ViewModel to the SelectedItem Property of WPF TreeGrid and UWP TreeGrid (SfTreeGrid).
You can bind the SelectedItem property directly to TreeGrid by setting the SfTreeGrid.SelectedItem property.
<syncfusion:SfTreeGrid Name="treeGrid"
Grid.Row="1"
ChildPropertyName="ReportsTo"
AutoExpandMode="AllNodesExpanded"
ShowRowHeader="True"
SelectedItem="{Binding SelectedItem, Mode=TwoWay,
UpdateSourceTrigger=PropertyChanged}"
AutoGenerateColumns="False"
ItemsSource="{Binding Employees}"
ParentPropertyName="ID"
SelfRelationRootValue="-1"/>
public class ViewModel: NotificationObject
{
private object selectedItem;
public object SelectedItem
{
get
{
return selectedItem;
}
set
{
selectedItem = value;
RaisePropertyChanged("SelectedItem");
}
}
}