Xamarin.Forms

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class SfTreeView

    Show / Hide Table of Contents

    Class SfTreeView

    A SfTreeView class provides a way to display the information in hierarchical structure.

    Inheritance
    System.Object
    SfTreeView
    Implements
    System.IDisposable
    Xamarin.Forms.IElementConfiguration<SfTreeView>
    Namespace: Syncfusion.XForms.TreeView
    Assembly: Syncfusion.SfTreeView.XForms.dll
    Syntax
    public class SfTreeView : View, IDisposable, IParentThemeElement, IThemeElement, IElementConfiguration<SfTreeView>

    Constructors

    SfTreeView()

    Initializes a new instance of the SfTreeView class.

    Declaration
    public SfTreeView()

    Fields

    AutoExpandModeProperty

    Identifies the AutoExpandMode bindable property.

    Declaration
    public static readonly BindableProperty AutoExpandModeProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    CheckBoxModeProperty

    Identifies the CheckBoxMode bindable property.

    Declaration
    public static readonly BindableProperty CheckBoxModeProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    CheckedItemsProperty

    Identifies the CheckedItems bindable property.

    Declaration
    public static readonly BindableProperty CheckedItemsProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    ChildPropertyNameProperty

    Identifies the ChildPropertyName bindable property.

    Declaration
    public static readonly BindableProperty ChildPropertyNameProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    CollapseCommandProperty

    Identifies the CollapseCommand bindable property.

    Declaration
    public static readonly BindableProperty CollapseCommandProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    CurrentItemProperty

    Identifies the CurrentItem dependency property.

    Declaration
    public static readonly BindableProperty CurrentItemProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    ExpandActionTargetProperty

    Identifies the ExpandActionTarget bindable property.

    Declaration
    public static readonly BindableProperty ExpandActionTargetProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    ExpandCommandProperty

    Identifies the ExpandCommand bindable property.

    Declaration
    public static readonly BindableProperty ExpandCommandProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    ExpanderPositionProperty

    Identifies the ExpanderPosition dependency property.

    Declaration
    public static readonly BindableProperty ExpanderPositionProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    ExpanderTemplateProperty

    Identifies the ExpanderTemplate bindable property.

    Declaration
    public static readonly BindableProperty ExpanderTemplateProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    ExpanderWidthProperty

    Identifies the ExpanderWidth bindable property.

    Declaration
    public static readonly BindableProperty ExpanderWidthProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    FocusBorderColorProperty

    Identifies the FocusBorderColor dependency property.

    Declaration
    public static readonly BindableProperty FocusBorderColorProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    FocusBorderThicknessProperty

    Identifies the FocusBorderThickness dependency property.

    Declaration
    public static readonly BindableProperty FocusBorderThicknessProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    FullRowSelectProperty

    Identifies the FullRowSelect dependency property.

    Declaration
    public static readonly BindableProperty FullRowSelectProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    HierarchyPropertyDescriptorsProperty

    Identifies the HierarchyPropertyDescriptors bindable property.

    Declaration
    public static readonly BindableProperty HierarchyPropertyDescriptorsProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    HoldCommandProperty

    Identifies the HoldCommand bindable property.

    Declaration
    public static readonly BindableProperty HoldCommandProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    IndentationProperty

    Identifies the Indentation bindable property.

    Declaration
    public static readonly BindableProperty IndentationProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    IsAnimationEnabledProperty

    Identifies the IsAnimationEnabled dependency property.

    Declaration
    public static readonly BindableProperty IsAnimationEnabledProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    IsScrollBarVisibleProperty

    Identifies the IsScrollBarVisible bindable property.

    Declaration
    public static readonly BindableProperty IsScrollBarVisibleProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    ItemHeightProperty

    Identifies the ItemHeight bindable property.

    Declaration
    public static readonly BindableProperty ItemHeightProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    ItemsSourceProperty

    Identifies the ItemsSource bindable property.

    Declaration
    public static readonly BindableProperty ItemsSourceProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    ItemTemplateContextTypeProperty

    Identifies the ItemTemplateContextType dependency property.

    Declaration
    public static readonly BindableProperty ItemTemplateContextTypeProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    ItemTemplateProperty

    Identifies the ItemTemplate bindable property.

    Declaration
    public static readonly BindableProperty ItemTemplateProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    LoadOnDemandCommandProperty

    Identifies the LoadOnDemandCommand bindable property.

    Declaration
    public static readonly BindableProperty LoadOnDemandCommandProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    NodePopulationModeProperty

    Identifies the NodePopulationMode bindable property.

    Declaration
    public static readonly BindableProperty NodePopulationModeProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    NodeSizeModeProperty

    Identifies the NodeSizeMode dependency property.

    Declaration
    public static readonly BindableProperty NodeSizeModeProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    NodesProperty

    Identifies the Nodes bindable property.

    Declaration
    public static readonly BindableProperty NodesProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    NotificationSubscriptionModeProperty

    Identifies the NotificationSubscriptionMode dependency property.

    Declaration
    public static readonly BindableProperty NotificationSubscriptionModeProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    SelectedItemProperty

    Identifies the SelectedItem dependency property.

    Declaration
    public static readonly BindableProperty SelectedItemProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    SelectedItemsProperty

    Identifies the SelectedItems dependency property.

    Declaration
    public static readonly BindableProperty SelectedItemsProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    SelectionBackgroundColorProperty

    Identifies the SelectionBackgroundColor dependency property.

    Declaration
    public static readonly BindableProperty SelectionBackgroundColorProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    SelectionForegroundColorProperty

    Identifies the SelectionForegroundColor dependency property.

    Declaration
    public static readonly BindableProperty SelectionForegroundColorProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    SelectionModeProperty

    Identifies the SelectionMode dependency property.

    Declaration
    public static readonly BindableProperty SelectionModeProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty

    TapCommandProperty

    Identifies the TapCommand bindable property.

    Declaration
    public static readonly BindableProperty TapCommandProperty
    Field Value
    Type Description
    Xamarin.Forms.BindableProperty
    Remarks

    This bindable property is read-only.

    Properties

    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.

    CheckBoxMode

    Gets or sets the value which indicates whether the CheckBoxMode is Individual or Recursive or None.

    Declaration
    public CheckBoxMode CheckBoxMode { get; set; }
    Property Value
    Type Description
    CheckBoxMode
    Remarks

    By default, it will be Nonei.e.,No update in any of the tree view node’s IsChecked property value.

    See Also
    CheckedItems
    GetCheckedNodes()
    ItemTemplateContextType

    CheckedItems

    Gets or sets list checked items list. Maintains list of data objects based on IsChecked.

    Declaration
    public ObservableCollection<object> CheckedItems { get; set; }
    Property Value
    Type Description
    System.Collections.ObjectModel.ObservableCollection<System.Object>
    Remarks

    This property maintains checked items only when you are binding ItemsSource to TreeView. To support recursive check programatically set CheckBoxMode as Recursive and NodePopulationMode as Instant. It does not support runtime changes in collection which is bind to CheckedItems.

    See Also
    GetCheckedNodes()
    CheckBoxMode
    ItemTemplateContextType

    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 Description
    System.String

    CollapseCommand

    Gets or sets the System.Windows.Input.ICommand which will be executed when the TreeViewNode is being collapsed.

    Declaration
    public ICommand CollapseCommand { get; set; }
    Property Value
    Type Description
    System.Windows.Input.ICommand
    Examples
    SfTreeView treeview = new SfTreeView();
    treeview.CollapseCommand = viewModel.CollapsingCommand;
    
    public class CommandViewModel
    {
      private Command<Object> collapsingCommand;
    
      public Command<object> CollapsingCommand
      {
          get { return collapsingCommand; }
          set { collapsingCommand = value; }
      }
    
      public CommandViewModel()
      {
          CollapsingCommand = new Command<object>(CollapsingCommandMethod);
      }
    
      private void CollapsingCommandMethod(object obj)
      {
    
    
      }
    }

    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 Description
    ExpandActionTarget

    ExpandCommand

    Gets or sets the System.Windows.Input.ICommand which will be executed when the TreeViewNode is being expanded.

    Declaration
    public ICommand ExpandCommand { get; set; }
    Property Value
    Type Description
    System.Windows.Input.ICommand
    Examples
    SfTreeView treeview = new SfTreeView();
    treeview.ExpandCommand = viewModel.ExpandingCommand;
    
    public class CommandViewModel
    {
      private Command<Object> expandingCommand;
    
      public Command<object> ExpandingCommand
      {
          get { return expandingCommand; }
          set { expandingCommand = value; }
      }
    
      public CommandViewModel()
      {
          ExpandingCommand = new Command<object>(ExpandingCommandMethod);
      }
    
      private void ExpandingCommandMethod(object obj)
      {
    
    
      }
    }

    ExpanderPosition

    Gets or sets the expander position in treeview. Default value is Start.

    Declaration
    public ExpanderPosition ExpanderPosition { get; set; }
    Property Value
    Type Description
    ExpanderPosition

    ExpanderTemplate

    Gets or sets the data template for the Expander View of tree view item in SfTreeView.

    Declaration
    public DataTemplate ExpanderTemplate { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.DataTemplate

    ExpanderWidth

    Gets or sets the width of expander in tree view item.

    Declaration
    public double ExpanderWidth { get; set; }
    Property Value
    Type Description
    System.Double

    FocusBorderColor

    Gets or sets the border color for the current focused item for UWP platform.

    Declaration
    public Color FocusBorderColor { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Color
    Remarks

    For Android and iOS platform, the default color is Xamarin.Forms.Color.Transparent and for UWP platform, the default color is Color.FromHex("#D5D5D5").

    FocusBorderThickness

    Gets or sets the border thickness for the current focused item for UWP platform.

    Declaration
    public Thickness FocusBorderThickness { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Thickness
    Remarks

    For Android and iOS platform, the default thickness is 0 and for UWP platform, the default thickness is 1.

    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 Description
    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 Description
    HierarchyPropertyDescriptors

    HoldCommand

    Gets or sets the System.Windows.Input.ICommand which will be executed when hold on the TreeViewNode.

    Declaration
    public ICommand HoldCommand { get; set; }
    Property Value
    Type Description
    System.Windows.Input.ICommand
    Examples
    SfTreeView treeview = new SfTreeView();
    treeview.HoldCommand = viewModel.HoldingCommand;
    public class CommandViewModel
    {
      private Command<Object> holdingCommand;
    
      public Command<object> HoldingCommand
      {
          get { return holdingCommand; }
          set { holdingCommand = value; }
      }
    
      public CommandViewModel()
      {
          HoldingCommand = new Command<object>(HoldingCommandMethod);
      }
    
      private void HoldingCommandMethod(object obj)
      {
    
    
      }
    }

    Indentation

    Gets or sets the distance to indent each child of tree view item in SfTreeView.

    Declaration
    public double Indentation { get; set; }
    Property Value
    Type Description
    System.Double

    IsAnimationEnabled

    Gets or sets a value indicating whether the selection spans the width of tree view control.

    Declaration
    public bool IsAnimationEnabled { get; set; }
    Property Value
    Type Description
    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 Description
    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 tree view item in SfTreeView.

    Declaration
    public double ItemHeight { get; set; }
    Property Value
    Type Description
    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 Description
    System.Object

    ItemTemplate

    Gets or sets the data template for the Content View of tree view item in SfTreeView.

    Declaration
    public DataTemplate ItemTemplate { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.DataTemplate

    ItemTemplateContextType

    Gets or sets the binding context type for treeview items. Note: It will be applicable for bound mode only. For Unbound mode, TreeViewNode will be the binding context for each treeview item.

    Declaration
    public ItemTemplateContextType ItemTemplateContextType { get; set; }
    Property Value
    Type Description
    ItemTemplateContextType
    Remarks

    CheckBoxMode and CheckedItems are applicable for only in Node.

    LoadOnDemandCommand

    Gets or sets the System.Windows.Input.ICommand which will be executed when tap on the expander.

    Declaration
    public ICommand LoadOnDemandCommand { get; set; }
    Property Value
    Type Description
    System.Windows.Input.ICommand
    Remarks

    It is applicable for bound mode only. Return true in CanExecute method of this command to enable expander icon and also to execute on demand loading for that node, else return false.

    NodePopulationMode

    Gets or sets the value that indicates whether the child nodes should be populated when treeview is loaded or when the node is expanded only.

    Declaration
    public TreeNodePopulationMode NodePopulationMode { get; set; }
    Property Value
    Type Description
    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 Description
    TreeViewNodeCollection

    NodeSizeMode

    Gets or sets the node size mode value that indicates whether dynamic size changes should be enabled or disabled for tree view items.

    Declaration
    public NodeSizeMode NodeSizeMode { get; set; }
    Property Value
    Type Description
    NodeSizeMode
    Remarks

    By default value, the NodeSizeMode is NodeSizeMode.None.

    NotificationSubscriptionMode

    Gets or sets the value that indicates whether to subscribe collection and property changes of data object to perform realtime 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 Description
    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 Description
    System.Collections.ObjectModel.ObservableCollection<System.Object>

    SelectionBackgroundColor

    Gets or sets the selection background color for the selected item.

    Declaration
    public Color SelectionBackgroundColor { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Color
    Remarks

    The default color is Color.FromHex("#F4F4F4").

    SelectionForegroundColor

    Gets or sets the selected item foreground color. Note: It will applicable for unbound mode only.

    Declaration
    public Color SelectionForegroundColor { get; set; }
    Property Value
    Type Description
    Xamarin.Forms.Color
    Remarks

    The default color is Color.FromHex("#007CEE").

    SelectionMode

    Gets or sets the selection mode for selection.

    Declaration
    public SelectionMode SelectionMode { get; set; }
    Property Value
    Type Description
    SelectionMode
    Remarks

    By default value, the SelectionMode is SelectionMode.Single.

    TapCommand

    Gets or sets the System.Windows.Input.ICommand which will be executed when tap on the TreeViewNode.

    Declaration
    public ICommand TapCommand { get; set; }
    Property Value
    Type Description
    System.Windows.Input.ICommand
    Examples
    SfTreeView treeview = new SfTreeView();
    treeview.TapCommand = viewModel.TappedCommand;
    
    public class CommandViewModel
    {
      private Command<Object> tappedCommand;
    
      public Command<object> TappedCommand
      {
          get { return tappedCommand; }
          set { tappedCommand = value; }
      }
    
      public CommandViewModel()
      {
          TappedCommand = new Command<object>(TappedCommandMethod);
      }
    
      private void TappedCommandMethod(object obj)
      {
    
    
      }
    }

    Methods

    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 tree view item 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 item)
    Parameters
    Type Name Description
    TreeViewNode item

    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 TreeViewItem from the view.

    Dispose()

    Dispose all the allocated resources.

    Declaration
    public void Dispose()

    Dispose(Boolean)

    Dispose the instances, if parameter is true.

    Declaration
    protected virtual 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 item)
    Parameters
    Type Name Description
    TreeViewNode item

    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.

    GetCheckedNodes()

    Get the all checked nodes in the SfTreeView. When binding ItemsSource, you can get the checked items list using CheckedItems.

    Declaration
    public ObservableCollection<TreeViewNode> GetCheckedNodes()
    Returns
    Type Description
    System.Collections.ObjectModel.ObservableCollection<TreeViewNode>

    Returns the collection of checked nodes.

    See Also
    CheckedItems
    CheckBoxMode
    ItemTemplateContextType

    On<T>()

    Method to get platform specific properties.

    Declaration
    public IPlatformElementConfiguration<T, SfTreeView> On<T>()
        where T : IConfigPlatform
    Returns
    Type Description
    Xamarin.Forms.IPlatformElementConfiguration<T, SfTreeView>

    Return platform specific properties.

    Type Parameters
    Name Description
    T

    Represents the platform type.

    OnMeasure(Double, Double)

    This method is called during the measure pass of a layout cycle to get the desired size of an element.

    Declaration
    protected override SizeRequest OnMeasure(double widthConstraint, double heightConstraint)
    Parameters
    Type Name Description
    System.Double widthConstraint

    The available width for the element to use.

    System.Double heightConstraint

    The available height for the element to use.

    Returns
    Type Description
    Xamarin.Forms.SizeRequest

    A Xamarin.Forms.SizeRequest which contains the desired size of the element.

    Remarks

    The results of this method will be (-1, -1) if the element has not yet been realized with a platform specific backing control. Overriding this method does not require a call to the base class so long as a valid SizeRequest is returned.

    RefreshView(Boolean)

    Refresh the treeviewitem in UI.

    Declaration
    public void RefreshView(bool canResetNodeView = false)
    Parameters
    Type Name Description
    System.Boolean canResetNodeView

    Indicates to reset tree node views.

    ResetTreeViewItems(Object)

    Method to reset the visible treeview item’s. If parameter is null, visible treeview items will reset else, particular treeview item will reset.

    Declaration
    public void ResetTreeViewItems(object dataObject = null)
    Parameters
    Type Name Description
    System.Object dataObject

    For Unbound mode, data represents the TreeViewNode and for Bound mode, it represents the data object associated with TreeViewNode.

    Events

    ItemDoubleTapped

    Occurs when the TreeViewItem's ContentView is double tapped.

    Declaration
    public event EventHandler<ItemDoubleTappedEventArgs> ItemDoubleTapped
    Event Type
    Type Description
    System.EventHandler<ItemDoubleTappedEventArgs>

    ItemHolding

    Occurs when the TreeViewItem's ContentView is long pressed.

    Declaration
    public event EventHandler<ItemHoldingEventArgs> ItemHolding
    Event Type
    Type Description
    System.EventHandler<ItemHoldingEventArgs>
    Remarks

    We can use the platform specific property Syncfusion.XForms.TreeView.PlatformConfiguration.WindowsSpecific.TreeView.HoldGesture(Xamarin.Forms.IPlatformElementConfiguration{Xamarin.Forms.PlatformConfiguration.Windows,Syncfusion.XForms.TreeView.SfTreeView}) for UWP platfom, to choose the intractions that supports for Holding an item. When Syncfusion.XForms.TreeView.PlatformConfiguration.WindowsSpecific.TreeView.HoldGesture(Xamarin.Forms.IPlatformElementConfiguration{Xamarin.Forms.PlatformConfiguration.Windows,Syncfusion.XForms.TreeView.SfTreeView}) is Hold, the holding event triggered only when hold by touch. When Syncfusion.XForms.TreeView.PlatformConfiguration.WindowsSpecific.TreeView.HoldGesture(Xamarin.Forms.IPlatformElementConfiguration{Xamarin.Forms.PlatformConfiguration.Windows,Syncfusion.XForms.TreeView.SfTreeView}) is HoldWithMouse, the holding event triggered only when hold using mouse pointer. The default value is Hold. This enumeration has a System.FlagsAttribute attribute that allows a bitwise combination of its member values. This is applicable only for UWP.

    Examples
    SfTreeView treeView = new SfTreeView();
    treeView.On<Windows>().SetHoldGesture(HoldGestureSettings.HoldWithMouse | HoldGestureSettings.Hold);

    ItemTapped

    Occurs when the TreeViewItem's ContentView is tapped.

    Declaration
    public event EventHandler<ItemTappedEventArgs> ItemTapped
    Event Type
    Type Description
    System.EventHandler<ItemTappedEventArgs>

    Loaded

    Occurs when the SfTreeView is loaded for the first time.

    Declaration
    public event EventHandler<TreeViewLoadedEventArgs> Loaded
    Event Type
    Type Description
    System.EventHandler<TreeViewLoadedEventArgs>

    NodeChecked

    Occurs when an IsChecked is being changed.

    Declaration
    public event EventHandler<NodeCheckedEventArgs> NodeChecked
    Event Type
    Type Description
    System.EventHandler<NodeCheckedEventArgs>

    NodeCollapsed

    Occurs when an TreeViewNode is collapsed.

    Declaration
    public event EventHandler<NodeExpandedCollapsedEventArgs> NodeCollapsed
    Event Type
    Type Description
    System.EventHandler<NodeExpandedCollapsedEventArgs>

    NodeCollapsing

    Occurs when an TreeViewNode is being collapsed.

    Declaration
    public event EventHandler<NodeExpandingCollapsingEventArgs> NodeCollapsing
    Event Type
    Type Description
    System.EventHandler<NodeExpandingCollapsingEventArgs>

    NodeExpanded

    Occurs when an TreeViewNode is expanded.

    Declaration
    public event EventHandler<NodeExpandedCollapsedEventArgs> NodeExpanded
    Event Type
    Type Description
    System.EventHandler<NodeExpandedCollapsedEventArgs>

    NodeExpanding

    Occurs when an TreeViewNode is being expanded.

    Declaration
    public event EventHandler<NodeExpandingCollapsingEventArgs> NodeExpanding
    Event Type
    Type Description
    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 Description
    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
    SfTreeView treeview = new SfTreeView();
    treeview += TreeView_QueryNodeSize;
    
    void TreeView_QueryNodeSize (object sender, QueryNodeSizeEventArgs e)
    {
     e.Height = e.GetActualNodeHeight();
     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 Description
    System.EventHandler<ItemSelectionChangedEventArgs>

    SelectionChanging

    Occurs while selecting an item's contentview at the execution time.

    Declaration
    public event EventHandler<ItemSelectionChangingEventArgs> SelectionChanging
    Event Type
    Type Description
    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.

    Implements

    System.IDisposable
    Xamarin.Forms.IElementConfiguration<>
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved