Skip to content

Commit f248b6f

Browse files
ES-975464 - Resolve ReadMe length Issues in this Repository
1 parent 7c44c7a commit f248b6f

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,42 @@
11
# how-to-bind-the-SelectedItem-property-of-wpf-tree-grid-in-mvvm
22

3-
This example illustrates to bind the SelectedItem property from ViewModel to treegrid.
3+
This example illustrates to bind the `SelectedItem` property from ViewModel to the [SelectedItem](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Grid.SfGridBase.html#Syncfusion_UI_Xaml_Grid_SfGridBase_SelectedItem) Property of [WPF TreeGrid](https://www.syncfusion.com/wpf-controls/treegrid) and [UWP TreeGrid](https://www.syncfusion.com/uwp-ui-controls/treegrid).
4+
5+
You can bind the `SelectedItem` property directly to `TreeGrid` by setting the [SfTreeGrid.SelectedItem](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.Grid.SfGridBase.html#Syncfusion_UI_Xaml_Grid_SfGridBase_SelectedItem) property.
6+
7+
## XAML code:
8+
9+
``` xml
10+
<syncfusion:SfTreeGrid Name="treeGrid"
11+
Grid.Row="1"
12+
ChildPropertyName="ReportsTo"
13+
AutoExpandMode="AllNodesExpanded"
14+
ShowRowHeader="True"
15+
SelectedItem="{Binding SelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
16+
AutoGenerateColumns="False"
17+
ItemsSource="{Binding Employees}"
18+
ParentPropertyName="ID"
19+
SelfRelationRootValue="-1"/>
20+
21+
```
22+
23+
## C# code:
24+
25+
``` C#
26+
public class ViewModel: NotificationObject
27+
{
28+
private object selectedItem;
29+
public object SelectedItem
30+
{
31+
get
32+
{
33+
return selectedItem;
34+
}
35+
set
36+
{
37+
selectedItem = value;
38+
RaisePropertyChanged("SelectedItem");
39+
}
40+
}
41+
}
42+
```

0 commit comments

Comments
 (0)