Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 42 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,54 @@
# How to get the node in WPF TreeView (SfTreeView)?
# How to Get the Node in WPF TreeView?

How to get the node in WPF TreeView (SfTreeView)?
This sample illustrates how to get the node in [WPF TreeView](https://www.syncfusion.com/wpf-controls/treeview) (SfTreeView).

# About the sample

In SfTreeView, you can get the node based on the item bound with it using SfTreeView.GetItemInfo method.
In `SfTreeView`, you can get the node based on the item bound with it using `SfTreeView.GetItemInfo` method.

#### XAML

``` xml
<syncfusion:SfTreeView x:Name="sfTreeView" Grid.Row="1" ExpandActionTrigger="Node" AutoExpandMode="AllNodes"
ChildPropertyName="SubFiles"
FullRowSelect="True"
ItemsSource="{Binding ImageNodeInfo}">
<syncfusion:SfTreeView.ItemTemplate>
<DataTemplate>
<Grid x:Name="grid">
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="20" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid>
<Image Source="{Binding ImageIcon}"
VerticalAlignment="Center"
HorizontalAlignment="Center"
Height="16"
Width="16"/>
</Grid>
<Grid Grid.Column="1"
Margin="1,0,0,0"
VerticalAlignment="Center">
<TextBlock Text="{Binding ItemName}"
Foreground="Black"
FontSize="13"
VerticalAlignment="Center" />
</Grid>
</Grid>
</Grid>
</DataTemplate>
</syncfusion:SfTreeView.ItemTemplate>
</syncfusion:SfTreeView>
```

#### C#

```c#
var treeViewInfo = sfTreeView.GetItemInfo((this.DataContext as FileManagerViewModel).ImageNodeInfo.FirstOrDefault(x => x.ItemName == "Documents"));
var node = treeViewInfo.Node;
```

KB article - [How to get the node in WPF TreeView (SfTreeView)?](https://www.syncfusion.com/kb/11991/how-to-get-the-node-in-wpf-treeview-sftreeview)

## Requirements to run the demo
Visual Studio 2015 and above versions