Skip to content

Latest commit

 

History

History
126 lines (75 loc) · 4.91 KB

scrolling.md

File metadata and controls

126 lines (75 loc) · 4.91 KB
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

Scrolling

You can enable users to scroll in the TreeView in both directions—horizontally and vertically—or choose only one direction.

Scroll Orientation

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.

.NET MAUI TreeView Horizontal Scrolling

Vertical Scrolling

Configure the vertical scrollbar by using the following properties:

  • VerticalScrollBarVisibility (enum of type Microsoft.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 type Telerik.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.

Horizontal Scrolling

Configure the horizontal scrollbar by using the following properties:

  • HorizontalScrollBarVisibility (enum of type Microsoft.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 type Telerik.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.

Example: Configuring the Scrollbar and Scroll Orientation

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:

.NET MAUI TreeView Scrollbars

Methods

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 is dataItem—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:

.NET MAUI TreeView Scroll to Item

Commands

In addition to the ScrollTo method, the TreeView exposes the ScrollToCommandthat 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.

See Also

  • [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%})