Skip to content

Commit b8bfcd2

Browse files
ES-975464 - Resolve the ReadMe issue in this sample repository
1 parent 23f15fd commit b8bfcd2

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

README.md

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,37 @@
1-
# How to autofit item height based on content in wpf treeview?
2-
This repository describes how to autofit item height based on content in wpf treeview
1+
# How to autofit item height based on content in WPF TreeView
2+
3+
This repository describes how to autofit item height based on content in [WPF TreeView](https://www.syncfusion.com/wpf-controls/treeview) (SfTreeView)
4+
5+
The `TreeView` allows adjusting height of items based on the content measured size while loaded by setting the `Height` argument with value returned from [QueryNodeSizeEventArgs.GetAutoFitNodeHeight](https://help.syncfusion.com/cr/wpf/Syncfusion.UI.Xaml.TreeView.QueryNodeSizeEventArgs.html#Syncfusion_UI_Xaml_TreeView_QueryNodeSizeEventArgs_GetAutoFitNodeHeight) method.
6+
7+
#### XAML
8+
9+
``` xml
10+
<syncfusion:SfTreeView x:Name="sfTreeView"
11+
Margin="10"
12+
QueryNodeSize="SfTreeView_QueryNodeSize"
13+
ExpandActionTrigger="Node"
14+
ItemsSource="{Binding Menu}" />
15+
```
16+
17+
#### C#
18+
19+
``` csharp
20+
sfTreeView.QueryNodeSize += SfTreeView_QueryNodeSize;
21+
22+
private void SfTreeView_QueryNodeSize(object sender, Syncfusion.UI.Xaml.TreeView.QueryNodeSizeEventArgs e)
23+
{
24+
if (e.Node.Level == 0)
25+
{
26+
//Returns specified item height for items.
27+
e.Height = 30;
28+
e.Handled = true;
29+
}
30+
else
31+
{
32+
// Returns item height based on the content loaded.
33+
e.Height = e.GetAutoFitNodeHeight();
34+
e.Handled = true;
35+
}
36+
}
37+
```

0 commit comments

Comments
 (0)