Class SfTreeView
Inheritance
Implements
Namespace: Syncfusion.iOS.TreeView
Assembly: Syncfusion.SfTreeView.iOS.dll
Syntax
public class SfTreeView : UIView, IDisposable, ITreeCollectionView, IComponent
Constructors
SfTreeView()
Initializes a new instance of the SfTreeView class.
Declaration
public SfTreeView()
SfTreeView(CGRect)
Initializes a new instance of the SfTreeView class.
Declaration
public SfTreeView(CGRect rect)
Parameters
Type | Name | Description |
---|---|---|
CoreGraphics.CGRect | rect | The CoreGraphics.CGRect. |
SfTreeView(IntPtr)
Initializes a new instance of the SfTreeView class.
Declaration
public SfTreeView(IntPtr ptr)
Parameters
Type | Name | Description |
---|---|---|
System.IntPtr | ptr | The System.IntPtr. |
Properties
Adapter
Gets or sets the TreeViewAdapter to customize the each TreeViewItem's.
Declaration
public TreeViewAdapter Adapter { get; set; }
Property Value
Type |
---|
TreeViewAdapter |
AutoExpandMode
Gets or sets the value which indicates how the nodes to be expanded while loading.
Declaration
public AutoExpandMode AutoExpandMode { get; set; }
Property Value
Type | Description |
---|---|
AutoExpandMode | The default value is None. |
ChildPropertyName
Gets or sets the property name for the child object where ItemsSource is used to define the items for this tree.
Declaration
public string ChildPropertyName { get; set; }
Property Value
Type |
---|
System.String |
CurrentItem
Gets or sets the current selected item.
Declaration
public object CurrentItem { get; set; }
Property Value
Type | Description |
---|---|
System.Object | The current item. |
ExpandActionTarget
Gets or sets a value indicating whether expanding and collapsing of nodes can be performed only by tapping in expander view or in both expander view and content view.
Declaration
public ExpandActionTarget ExpandActionTarget { get; set; }
Property Value
Type |
---|
ExpandActionTarget |
ExpanderPosition
Gets or sets the expander position in SfTreeView. Default value is Start.
Declaration
public ExpanderPosition ExpanderPosition { get; set; }
Property Value
Type |
---|
ExpanderPosition |
ExpanderWidth
Gets or sets the width of expander in TreeViewItem.
Declaration
public double ExpanderWidth { get; set; }
Property Value
Type |
---|
System.Double |
FullRowSelect
Gets or sets a value indicating whether the selection spans the width of tree view control.
Declaration
public bool FullRowSelect { get; set; }
Property Value
Type |
---|
System.Boolean |
Remarks
Default value false, where the selection start from indent level only.
HierarchyPropertyDescriptors
Gets or sets the list of HierarchyPropertyDescriptors which holds list of HierarchyPropertyDescriptor that provides information of type and property name. TreeView generates the child nodes based ChildPropertyName if the type of data object matches TargetType.
Declaration
public HierarchyPropertyDescriptors HierarchyPropertyDescriptors { get; set; }
Property Value
Type |
---|
HierarchyPropertyDescriptors |
Indentation
Gets or sets the distance to indent each child TreeViewItem.
Declaration
public double Indentation { get; set; }
Property Value
Type |
---|
System.Double |
IsAnimationEnabled
Gets or sets a value indicating whether to enable animation while expanding and collapse items.
Declaration
public bool IsAnimationEnabled { get; set; }
Property Value
Type |
---|
System.Boolean |
IsScrollBarVisible
Gets or sets a value indicating whether to display the scrollbar or not.
Declaration
public bool IsScrollBarVisible { get; set; }
Property Value
Type |
---|
System.Boolean |
Remarks
ScrollBar cannot be updated at runtime.
Examples
SfTreeView treeView = new SfTreeView();
treeView.IsScrollBarVisible = true;
ItemHeight
Gets or sets the height of each TreeViewItem in SfTreeView.
Declaration
public double ItemHeight { get; set; }
Property Value
Type |
---|
System.Double |
ItemsSource
Gets or sets the source items to the template and display in SfTreeView.
Declaration
public object ItemsSource { get; set; }
Property Value
Type |
---|
System.Object |
NodePopulationMode
Gets or sets the value that indicates whether the child nodes should be populated when SfTreeView is loaded or when the node is expanded only.
Declaration
public TreeNodePopulationMode NodePopulationMode { get; set; }
Property Value
Type |
---|
TreeNodePopulationMode |
Remarks
When NodePopulationMode is OnDemand, the child nodes will be populated when the parent nodes are expanded only. When NodePopulationMode is Instant, all the nodes will be populated when SfTreeView initially loaded. The default value is OnDemand. This property is applicable for Bound mode only.
Nodes
Gets or sets the collection of tree view nodes that are assigned to tree view control in Unbound mode..
Declaration
public TreeViewNodeCollection Nodes { get; set; }
Property Value
Type |
---|
TreeViewNodeCollection |
NotificationSubscriptionMode
Gets or sets the value that indicates whether to subscribe collection and property changes of data object to perform real time data update. When binding ItemsSource, TreeView subscribes to collection and property changes of data object based on NotificationSubscriptionMode.
Declaration
public NotificationSubscriptionMode NotificationSubscriptionMode { get; set; }
Property Value
Type |
---|
NotificationSubscriptionMode |
Remarks
When NotificationSubscriptionMode is CollectionChange, TreeView updated its tree structure when child items collection gets changed. When NotificationSubscriptionMode is Property change, TreeView updates its ChildItems when associated collection property gets changed. The default value is None.
Examples
SfTreeView treeView = new SfTreeView();
treeView.NotificationSubscriptionMode = NotificationSubscriptionMode.CollectionChange | NotificationSubscriptionMode.PropertyChange;
SelectedItem
Gets or sets the first selected item.
Declaration
public object SelectedItem { get; set; }
Property Value
Type | Description |
---|---|
System.Object | The selected item. |
SelectedItems
Gets or sets the selected items for selection.
Declaration
public ObservableCollection<object> SelectedItems { get; set; }
Property Value
Type |
---|
System.Collections.ObjectModel.ObservableCollection<System.Object> |
SelectionBackgroundColor
Gets or sets the selection background color for the selected item.
Declaration
public UIColor SelectionBackgroundColor { get; set; }
Property Value
Type |
---|
UIKit.UIColor |
SelectionController
Gets or sets the SelectionController to process and update the selections for TreeViewItem.
Declaration
public SelectionController SelectionController { get; set; }
Property Value
Type |
---|
SelectionController |
SelectionForegroundColor
Gets or sets the selected item foreground color. Note: It will applicable for unbound mode only.
Declaration
public UIColor SelectionForegroundColor { get; set; }
Property Value
Type |
---|
UIKit.UIColor |
SelectionMode
Gets or sets the selection mode for selection.
Declaration
public SelectionMode SelectionMode { get; set; }
Property Value
Type |
---|
SelectionMode |
Remarks
By default value, the SelectionMode is SelectionMode.Single.
Site
Gets or sets the ISite associated with the IComponent.
Declaration
public ISite Site { get; set; }
Property Value
Type |
---|
System.ComponentModel.ISite |
Methods
AwakeFromNib()
Helper method to initialise view in designer.
Declaration
public override void AwakeFromNib()
BringIntoView(TreeViewNode, Boolean, Boolean, ScrollToPosition)
Attempts to bring the tree view item into view by scrolling.
Declaration
public void BringIntoView(TreeViewNode item, bool disableAnimation = false, bool canExpand = false, ScrollToPosition scrollToPosition)
Parameters
Type | Name | Description |
---|---|---|
TreeViewNode | item | Represents the TreeViewNode to scroll. |
System.Boolean | disableAnimation | true to disable scroll animation while changing the view; otherwise, false. The default is false. |
System.Boolean | canExpand | true to expand the collapsed nodes and bring the collapsed node into view; otherwise, false. The default is false. |
ScrollToPosition | scrollToPosition | Defines position in the view to which node is scrolled. |
Remarks
Need to set NodePopulationMode property to Instant for populating all the nodes to bring the collapsed node into view while calling this method with 'canExpand' parameter as true.
BringIntoView(Object, Boolean, Boolean, ScrollToPosition)
Attempts to bring the TreeViewItem into view by scrolling.
Declaration
public void BringIntoView(object dataObject, bool disableAnimation = false, bool canExpand = false, ScrollToPosition scrollToPosition)
Parameters
Type | Name | Description |
---|---|---|
System.Object | dataObject | Represents the data object associated with TreeViewNode to scroll. |
System.Boolean | disableAnimation | true to disable scroll animation while changing the view; otherwise, false. The default is false. |
System.Boolean | canExpand | true to expand the collapsed nodes and bring the collapsed node into view; otherwise, false. The default is false. |
ScrollToPosition | scrollToPosition | Defines position in the view to which object is scrolled. |
Remarks
Need to set NodePopulationMode property to Instant for populating all the nodes to bring the collapsed node into view while calling this method with 'canExpand' parameter as true.
CollapseAll()
Collapses all the nodes in the SfTreeView.
Declaration
public void CollapseAll()
CollapseNode(TreeViewNode)
Collapses the specified TreeViewNode.
Declaration
public void CollapseNode(TreeViewNode treeViewNode)
Parameters
Type | Name | Description |
---|---|---|
TreeViewNode | treeViewNode | Specifies the TreeViewNode to collapse it from the view. |
CollapseNodes(Int32)
Collapses all the tree view items based on the specified level.
Declaration
public void CollapseNodes(int level = -1)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | level | Specifies the level of TreeViewNode to collapse all the TreeViewItems from the view. |
Dispose(Boolean)
Dispose the instances, if parameter is true.
Declaration
protected override void Dispose(bool disposing)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | disposing | Represents the boolean value for disposing objects. |
ExpandAll()
Expands all the nodes in the SfTreeView.
Declaration
public void ExpandAll()
ExpandNode(TreeViewNode)
Expands the specified TreeViewNode.
Declaration
public void ExpandNode(TreeViewNode treeViewNode)
Parameters
Type | Name | Description |
---|---|---|
TreeViewNode | treeViewNode | Specifies the TreeViewNode to expand it in the view. |
ExpandNodes(Int32)
Expands all the tree view items based on the specified level.
Declaration
public void ExpandNodes(int level = -1)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | level | Specifies the level of TreeViewNode to expand all the TreeViewItems in the view. |
LayoutSubviews()
Layouts the SfTreeView when bounds or sub views gets changed.
Declaration
public override void LayoutSubviews()
RefreshView()
Refresh the TreeViewItem in UI.
Declaration
public void RefreshView()
ResetTreeViewItems(Object)
Method to reset the visible TreeViewItem’s. If parameter is null, visible tree view items will reset else, particular TreeViewItem will reset.
Declaration
public void ResetTreeViewItems(object data = null)
Parameters
Type | Name | Description |
---|---|---|
System.Object | data | For Unbound mode, data represents the TreeViewNode and for Bound mode, it represents the data object associated with TreeViewNode. |
SelectAll()
Select all the items in the SfTreeView.
Declaration
public void SelectAll()
Events
Disposed
Represents the method that handles the Disposed event of a component.
Declaration
public event EventHandler Disposed
Event Type
Type |
---|
System.EventHandler |
ItemDoubleTapped
Occurs when the TreeViewItem's ContentView is double tapped.
Declaration
public event EventHandler<ItemDoubleTappedEventArgs> ItemDoubleTapped
Event Type
Type |
---|
System.EventHandler<ItemDoubleTappedEventArgs> |
ItemHolding
Occurs when the TreeViewItem's ContentView is long pressed.
Declaration
public event EventHandler<ItemHoldingEventArgs> ItemHolding
Event Type
Type |
---|
System.EventHandler<ItemHoldingEventArgs> |
ItemTapped
Occurs when the TreeViewItem's ContentView is tapped.
Declaration
public event EventHandler<ItemTappedEventArgs> ItemTapped
Event Type
Type |
---|
System.EventHandler<ItemTappedEventArgs> |
Loaded
Occurs when the SfTreeView is loaded for the first time.
Declaration
public event EventHandler<TreeViewLoadedEventArgs> Loaded
Event Type
Type |
---|
System.EventHandler<TreeViewLoadedEventArgs> |
LoadOnDemand
Occurs when the TreeViewItem is loaded at run time.
Declaration
public event EventHandler<LoadOnDemandEventArgs> LoadOnDemand
Event Type
Type |
---|
System.EventHandler<LoadOnDemandEventArgs> |
Examples
SfTreeView treeView = new SfTreeView();
treeView.LoadOnDemand += TreeView_LoadOnDemandEvent;
private async void TreeView_LoadOnDemandEvent(object sender, LoadOnDemandEventArgs e)
{
if (e.Action == LoadOnDemandAction.RequestStatus)
{
...
if (!hasChildNodes)
{
e.HasChildNodes = false;
return;
}
e.HasChildNodes = true;
}
else if(e.Action == Action.PopulateNodes)
{
...
node.ShowExpanderAnimation = true;
...
node.PopulateChildNodes(items);
if (items.Count() > 0)
node.IsExpanded = true;
node.ShowExpanderAnimation = false;
}
}
NodeCollapsed
Occurs when an TreeViewNode is collapsed.
Declaration
public event EventHandler<NodeExpandedCollapsedEventArgs> NodeCollapsed
Event Type
Type |
---|
System.EventHandler<NodeExpandedCollapsedEventArgs> |
NodeCollapsing
Occurs when an TreeViewNode is being collapsed.
Declaration
public event EventHandler<NodeExpandingCollapsingEventArgs> NodeCollapsing
Event Type
Type |
---|
System.EventHandler<NodeExpandingCollapsingEventArgs> |
NodeExpanded
Occurs when an TreeViewNode is expanded.
Declaration
public event EventHandler<NodeExpandedCollapsedEventArgs> NodeExpanded
Event Type
Type |
---|
System.EventHandler<NodeExpandedCollapsedEventArgs> |
NodeExpanding
Occurs when an TreeViewNode is being expanded.
Declaration
public event EventHandler<NodeExpandingCollapsingEventArgs> NodeExpanding
Event Type
Type |
---|
System.EventHandler<NodeExpandingCollapsingEventArgs> |
QueryNodeSize
Occurs whenever an item comes into view and query the item size.
Declaration
public event EventHandler<QueryNodeSizeEventArgs> QueryNodeSize
Event Type
Type |
---|
System.EventHandler<QueryNodeSizeEventArgs> |
Remarks
SfTreeView supports auto height feature, by using this event. We can define whether the specified size can be set to the item or not by handling the QueryNodeSize event.
Examples
This example demonstrates how to handle QueryNodeSize event.
using Syncfusion.Android.TreeView;
SfTreeView treeView = new SfTreeView();
treeView.QueryNodeSize += TreeView_QueryNodeSize;
void TreeView_QueryNodeSize (object sender, QueryNodeSizeEventArgs e)
{
e.Height = 40;
e.Handled = true;
}
SelectionChanged
Occurs once the selection process has been completed for the selected item in the SfTreeView.
Declaration
public event EventHandler<ItemSelectionChangedEventArgs> SelectionChanged
Event Type
Type |
---|
System.EventHandler<ItemSelectionChangedEventArgs> |
SelectionChanging
Occurs while selecting an item's contentview at the execution time.
Declaration
public event EventHandler<ItemSelectionChangingEventArgs> SelectionChanging
Event Type
Type |
---|
System.EventHandler<ItemSelectionChangingEventArgs> |
Remarks
The SelectionChanging event is a cancelable event and can be canceled by handling the event and setting the Cancel property to true. However, if the event is canceled, the selection process for the selected TreeViewItem's contentview gets cancelled.