Skip to content

Commit 0e17a3b

Browse files
ES-975464 - Changed committed
1 parent f248b6f commit 0e17a3b

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
# how-to-bind-the-SelectedItem-property-of-wpf-tree-grid-in-mvvm
1+
# How to Bind the SelectedItem Property of WPF TreeGrid in MVVM?
22

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).
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) (SfTreeGrid).
44

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.
5+
You can bind the **SelectedItem** property directly to TreeGrid by setting the **SfTreeGrid.SelectedItem** property.
66

7-
## XAML code:
7+
### XAML:
88

99
``` xml
1010
<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"/>
11+
Grid.Row="1"
12+
ChildPropertyName="ReportsTo"
13+
AutoExpandMode="AllNodesExpanded"
14+
ShowRowHeader="True"
15+
SelectedItem="{Binding SelectedItem, Mode=TwoWay,
16+
UpdateSourceTrigger=PropertyChanged}"
17+
AutoGenerateColumns="False"
18+
ItemsSource="{Binding Employees}"
19+
ParentPropertyName="ID"
20+
SelfRelationRootValue="-1"/>
2021

2122
```
2223

23-
## C# code:
24+
### C#:
2425

2526
``` C#
2627
public class ViewModel: NotificationObject

0 commit comments

Comments
 (0)