title | page_title | description | position | slug |
---|---|---|---|---|
Scrolling |
.NET MAUI TreeView Documentation - Scrolling |
Review the horizontal and vertical scrolling options available in TreeView for .NET MAUI. |
6 |
treeview-scrolling |
You can enable users to scroll in the TreeView in both directions—horizontally and vertically—or choose only one direction.
To configure the scroll direction for the TreeView items, use the ScrollOrientation
(enum of type Telerik.Maui.Controls.TreeView.TreeViewScrollOrientation
) property. It accepts the following values:
- (Default value)
Vertical
—Allows the user to scroll the TreeView only in a vertical direction. Both
—Allows the user to scroll the TreeView both in a vertical and horizontal direction.
Configure the vertical scrollbar by using the following properties:
-
VerticalScrollBarVisibility
(enum of typeMicrosoft.Maui.ScrollBarVisibility
)—Specifies the visibility of the vertical scrollbar. The available options are:Default
—Applies the default visibility for the platform based on the content and orientation.Always
—The scrollbar is visible, regardless of the content or orientation.Never
—The scrollbar is not visible.
-
VerticalScrollBarLayoutMode
(enum of typeTelerik.Maui.Controls.ItemsView.ScrollBarLayoutMode
)—Specifies the layout mode of the vertical scrollbar. The available options are:Overlay
—The scrollbars overlay the scrollable content when visible.Resize
—The scrollbars resize the scrollable content when visible.
Configure the horizontal scrollbar by using the following properties:
-
HorizontalScrollBarVisibility
(enum of typeMicrosoft.Maui.ScrollBarVisibility
)—Specifies the visibility of the horizontal scrollbar. The available options are:Default
—Applies the default visibility for the platform based on the content and orientation.Always
—The scrollbar is visible, regardless of the content or orientation.Never
—The scrollbar is not visible.
-
HorizontalScrollBarLayoutMode
(enum of typeTelerik.Maui.Controls.ItemsView.ScrollBarLayoutMode
)—Specifies the layout mode of the horizontal scrollbar. The available options are:Overlay
—The scrollbars overlay the scrollable content when visible.Resize
—The scrollbars resize the scrollable content when visible.
The following example demonstrates how to configure horizontal and vertical scrolling when working with the .NET MAUI TreeView control.
1. Define the RadTreeView
control:
2. Add the location data model:
3. Add the country data model:
4. Add the city data model:
5. Add the ViewModel:
The TreeView provides the ScrollTo
method that allows you to configure the control to display a specific item:
ScrollTo
(object dataItem
)—Scrolls the visible area of the control so that the specified item is visible. The parameter isdataItem
—Specifies the item to scroll to.
The example below demonstrates how to use the ScrollTo
method.
1. Define the RadTreeview
control:
2. Configure the ScrollTo
executon on button click:
3. Add the location data model:
4. Add the country data model:
5. Add the city data model:
6. Add the ViewModel:
In addition to the ScrollTo
method, the TreeView exposes the ScrollToCommand
that allows you to configure the control to display a specific item:
ScrollToCommand
(ICommand
)—Gets a command that scrolls to an item in the control, which is specified as a parameter.
For a runnable example demonstrating the TreeView scrolling feature, see the [SDKBrowser Demo Application]({%slug sdkbrowser-app%}) and go to TreeView > Scrolling.
- [Expand and Collapse TreeView Items]({%slug treeview-expand-collapse%})
- [CheckBoxes in TreeView]({%slug treeview-checkboxes%})
- [Styling the TreeView Item]({%slug treeview-item-style%})
- [Multiple and Single Selection]({%slug treeview-selection%})
- [Events]({%slug treeview-events%})
- [Available Commands in .NET MAUI TreeView]({%slug treeview-commands%})