Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/syncfusionexamples/xamarin-treeview-item-height-customization
This repository contains the sample which demonstrates how to autofit the TreeView item height based on its content size
https://github.com/syncfusionexamples/xamarin-treeview-item-height-customization
autofit treeview treeviewnode xamarin xamarin-forms
Last synced: 27 days ago
JSON representation
This repository contains the sample which demonstrates how to autofit the TreeView item height based on its content size
- Host: GitHub
- URL: https://github.com/syncfusionexamples/xamarin-treeview-item-height-customization
- Owner: SyncfusionExamples
- Created: 2019-07-19T10:31:39.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-02-15T13:46:51.000Z (11 months ago)
- Last Synced: 2024-04-14T12:07:22.641Z (9 months ago)
- Topics: autofit, treeview, treeviewnode, xamarin, xamarin-forms
- Homepage:
- Size: 593 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# How to autofit the items based on the content in Xamarin Forms TreeView?
In TreeView, you can customize each item size by using the [QueryNodeSize](https://help.syncfusion.com/cr/xamarin/Syncfusion.SfTreeView.XForms~Syncfusion.XForms.TreeView.SfTreeView~QueryNodeSize_EV.html) event. In this event, the [Handled](https://help.syncfusion.com/cr/xamarin/Syncfusion.SfTreeView.XForms~Syncfusion.XForms.TreeView.QueryNodeSizeEventArgs~Handled.html) property indicates whether to set specified size for an item or not by its Boolean value. This event is raised when an item comes in view with the [QueryNodeSizeEventArgs](https://help.syncfusion.com/cr/xamarin/Syncfusion.SfTreeView.XForms~Syncfusion.XForms.TreeView.QueryNodeSizeEventArgs.html) argument.
```xml
```
The [QueryNodeSizeEventArgs.GetActualNodeHeight](https://help.syncfusion.com/cr/cref_files/xamarin/Syncfusion.SfTreeView.XForms~Syncfusion.XForms.TreeView.QueryNodeSizeEventArgs~GetActualNodeHeight.html) method of [QueryNodeSizeEventArgs](https://help.syncfusion.com/cr/xamarin/Syncfusion.SfTreeView.XForms~Syncfusion.XForms.TreeView.QueryNodeSizeEventArgs.html) is used to get the measured height of the item based on content and it is set to the [QueryNodeSizeEventArgs.Height](https://help.syncfusion.com/cr/cref_files/xamarin/Syncfusion.SfTreeView.XForms~Syncfusion.XForms.TreeView.QueryNodeSizeEventArgs~Height.html) property.```c#
private void TreeView_QueryNodeSize(object sender, QueryNodeSizeEventArgs e)
{
if (e.Node.Level == 0)
{
//Returns speified item height for item.
e.Height = 200;
e.Handled = true;
}
else
{
// Returns measured height based on the content loaded.
e.Height = e.GetActualNodeHeight();
e.Handled = true;
}
}```