Migrate from Xamarin.Forms SfTreeView to .NET MAUI SfTreeView

9 Jul 20263 minutes to read

To make it easier to migrate from Xamarin SfTreeView to .NET MAUI SfTreeView, we retained most of the APIs from the Xamarin SfTreeView in the .NET MAUI SfTreeView. To keep API naming consistent in the .NET MAUI SfTreeView, however, we renamed some APIs. The APIs that have changed from the Xamarin SfTreeView to the .NET MAUI SfTreeView are detailed as follows.

NOTE
The tables below list only the APIs whose names changed. All other APIs from the Xamarin SfTreeView are retained in the .NET MAUI SfTreeView under the new namespace.

Namespaces

Xamarin SfTreeView .NET MAUI SfTreeView
Syncfusion.XForms.TreeView Syncfusion.Maui.TreeView

The C# namespace changes from Syncfusion.XForms.TreeView to Syncfusion.Maui.TreeView. The following XAML xmlns declarations must also be updated:

API scope Xamarin SfTreeView .NET MAUI SfTreeView
XAML namespace xmlns:syncfusion="clr-namespace:Syncfusion.XForms.TreeView;assembly=Syncfusion.SfTreeView.XForms" xmlns:syncfusion="clr-namespace:Syncfusion.Maui.TreeView;assembly=Syncfusion.Maui.TreeView"

Properties

The following table lists the properties whose names changed in the .NET MAUI SfTreeView:

Xamarin SfTreeView .NET MAUI SfTreeView Description

HoldCommand

LongPressCommand

Gets or sets a System.Windows.Input.ICommand that will be executed when the TreeViewItem is long-pressed. Note: In MAUI, the command parameter is of type `TreeViewLongPressCommandParameter`; update command bindings accordingly.

IsScrollBarVisible

ScrollBarVisibility

Gets or sets a value indicating whether the scrollbar should be displayed. Note: The property type changed from a Boolean (`IsScrollBarVisible`) in Xamarin to the [`ScrollBarVisibility`](https://help.syncfusion.com/cr/maui/Syncfusion.Maui.TreeView.ScrollBarVisibility.html) enum in MAUI — set it to `Default`, `Always`, `Never`, or `Disabled`.

SelectionBackgroundColor

SelectionBackground

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

SelectionForegroundColor

SelectionForeground

Gets or sets the selected item's foreground color. Note: It is applicable in unbound mode only. The same restriction applies to the .NET MAUI SfTreeView — `SelectionForeground` is applied only in unbound mode.

Enums

The following table lists the enums whose names changed in the .NET MAUI SfTreeView. The enum members themselves are unchanged from Xamarin to MAUI; only the type names changed:

Xamarin SfTreeView .NET MAUI SfTreeView Description

ItemType

TreeViewItemType

Defines the item type for a TreeViewItemInfoBase.

ExpandActionTarget

TreeViewExpandActionTarget

Defines whether expanding and collapsing of nodes can be performed only by tapping the expander view, or by tapping both the expander view and the content view.

ExpanderPosition

TreeViewExpanderPosition

Defines the expander position of the SfTreeView. The expander can be positioned at either the start or the end of the item.

SelectionMode

TreeViewSelectionMode

Defines constants that specify the selection modes supported by the SfTreeView control.

AutoExpandMode

TreeViewAutoExpandMode

Defines the possible expand modes while loading the nodes in the SfTreeView. Note: In Xamarin, this enum lived in the `Syncfusion.TreeView.Engine` namespace; in .NET MAUI, it has moved to `Syncfusion.Maui.TreeView` and been renamed.

NotificationSubscriptionMode

TreeViewNotificationSubscriptionMode

Defines the constants that specify whether to listen for the PropertyChanging and `System.ComponentModel.INotifyPropertyChanged.PropertyChanged` events of the data object, and the `System.Collections.Specialized.INotifyCollectionChanged.CollectionChanged` event of the source collection. Note: In Xamarin, this enum lived in the `Syncfusion.TreeView.Engine` namespace; in .NET MAUI, it has moved to `Syncfusion.Maui.TreeView` and been renamed.

Events

The only renamed event in the .NET MAUI SfTreeView is listed below. Its associated event-arguments class is also renamed:

Xamarin SfTreeView .NET MAUI SfTreeView Description

ItemHolding

ItemLongPress

Occurs when the TreeViewItem's content view is long-pressed.

ItemHoldingEventArgs

ItemLongPressEventArgs

Provides data for the `ItemHolding` (Xamarin) and `ItemLongPress` (.NET MAUI) events.

Methods, interfaces, and attached properties

No public methods, interfaces, or bindable (attached) properties were renamed in the .NET MAUI SfTreeView. They are retained from the Xamarin SfTreeView under the new namespace. For any API not listed in the tables above, simply update its namespace from Syncfusion.XForms.TreeView to Syncfusion.Maui.TreeView.