Table of Contents

Class VirtualScroll

Namespace
Nalu
Assembly
Nalu.Maui.VirtualScroll.dll

A scrollable view that virtualizes its content.

public class VirtualScroll : View, INotifyPropertyChanged, IVisualTreeElement, IEffectControlProvider, IToolTipElement, IContextFlyoutElement, IAnimatable, IViewController, IVisualElementController, IElementController, IGestureController, IGestureRecognizers, IPropertyMapperView, IHotReloadableView, IReplaceableView, IVirtualScroll, IView, IElement, ITransform, IEquatable<IVirtualScrollLayoutInfo>, IVirtualScrollController
Inheritance
VirtualScroll
Implements
IEquatable<IVirtualScrollLayoutInfo>
Inherited Members

Remarks

This control is designed to replace traditional CollectionView control by providing a more efficient implementation tailored for Android and iOS platforms.

Fields

AdapterProperty

Bindable property for Adapter.

public static readonly BindableProperty AdapterProperty

Field Value

BindableProperty

FadingEdgeLengthProperty

Bindable property for FadingEdgeLength.

public static readonly BindableProperty FadingEdgeLengthProperty

Field Value

BindableProperty

FooterTemplateProperty

Bindable property for FooterTemplate.

public static readonly BindableProperty FooterTemplateProperty

Field Value

BindableProperty

HeaderTemplateProperty

Bindable property for HeaderTemplate.

public static readonly BindableProperty HeaderTemplateProperty

Field Value

BindableProperty

IsRefreshEnabledProperty

Bindable property for IsRefreshEnabled.

public static readonly BindableProperty IsRefreshEnabledProperty

Field Value

BindableProperty

IsRefreshingProperty

Bindable property for IsRefreshing.

public static readonly BindableProperty IsRefreshingProperty

Field Value

BindableProperty

ItemTemplateProperty

Bindable property for ItemTemplate.

public static readonly BindableProperty ItemTemplateProperty

Field Value

BindableProperty

ItemsLayoutProperty

Bindable property for ItemsLayout.

public static readonly BindableProperty ItemsLayoutProperty

Field Value

BindableProperty

RefreshAccentColorProperty

Bindable property for RefreshAccentColor.

public static readonly BindableProperty RefreshAccentColorProperty

Field Value

BindableProperty

RefreshCommandProperty

Bindable property for RefreshCommand.

public static readonly BindableProperty RefreshCommandProperty

Field Value

BindableProperty

ScrolledCommandProperty

Bindable property for ScrolledCommand.

public static readonly BindableProperty ScrolledCommandProperty

Field Value

BindableProperty

SectionFooterTemplateProperty

Bindable property for SectionFooterTemplate.

public static readonly BindableProperty SectionFooterTemplateProperty

Field Value

BindableProperty

SectionHeaderTemplateProperty

Bindable property for SectionHeaderTemplate.

public static readonly BindableProperty SectionHeaderTemplateProperty

Field Value

BindableProperty

Properties

Adapter

The adapter that provides data to the virtual scroll.

public object? Adapter { get; set; }

Property Value

object

FadingEdgeLength

Gets or sets the length of the fading edge effect in device-independent units.

public double FadingEdgeLength { get; set; }

Property Value

double

Remarks

A value of 0 means no fading edge is applied (default). The orientation of the fading edge is determined by the layout orientation (horizontal or vertical).

FooterTemplate

Gets or sets the template used to display the footer at the bottom of the scroll view.

public DataTemplate? FooterTemplate { get; set; }

Property Value

DataTemplate

HeaderTemplate

Gets or sets the template used to display the header at the top of the scroll view.

public DataTemplate? HeaderTemplate { get; set; }

Property Value

DataTemplate

IsRefreshEnabled

Gets or sets a value indicating whether pull-to-refresh is enabled.

public bool IsRefreshEnabled { get; set; }

Property Value

bool

IsRefreshing

Gets or sets a value indicating whether the refresh indicator is currently showing. Setting this to true programmatically will trigger the refresh indicator. Setting this to false will stop the refresh indicator.

public bool IsRefreshing { get; set; }

Property Value

bool

ItemTemplate

Gets or sets the template used to display each item.

public DataTemplate? ItemTemplate { get; set; }

Property Value

DataTemplate

ItemsLayout

Gets or sets the layout for the virtual scroll.

public IVirtualScrollLayout ItemsLayout { get; set; }

Property Value

IVirtualScrollLayout

RefreshAccentColor

Gets or sets the accent color for the refresh indicator.

public Color? RefreshAccentColor { get; set; }

Property Value

Color

RefreshCommand

Gets or sets the command to execute when the user requests a refresh.

public ICommand? RefreshCommand { get; set; }

Property Value

ICommand

ScrolledCommand

Gets or sets the command to execute when the scroll position changes.

public ICommand? ScrolledCommand { get; set; }

Property Value

ICommand

SectionFooterTemplate

Gets or sets the template used to display section footers.

public DataTemplate? SectionFooterTemplate { get; set; }

Property Value

DataTemplate

SectionHeaderTemplate

Gets or sets the template used to display section headers.

public DataTemplate? SectionHeaderTemplate { get; set; }

Property Value

DataTemplate

Methods

CreateObservableCollectionAdapter<T>(ObservableCollection<T>)

Creates a virtual scroll adapter for the specified observable collection.

public static IVirtualScrollAdapter CreateObservableCollectionAdapter<T>(ObservableCollection<T> collection)

Parameters

collection ObservableCollection<T>

Returns

IVirtualScrollAdapter

Type Parameters

T

CreateObservableCollectionAdapter<T>(ReadOnlyObservableCollection<T>)

Creates a virtual scroll adapter for the specified observable collection.

public static IVirtualScrollAdapter CreateObservableCollectionAdapter<T>(ReadOnlyObservableCollection<T> collection)

Parameters

collection ReadOnlyObservableCollection<T>

Returns

IVirtualScrollAdapter

Type Parameters

T

CreateObservableCollectionAdapter<TSection, TItem>(ObservableCollection<TSection>, Func<TSection, ObservableCollection<TItem>>)

Creates a grouped virtual scroll adapter for the specified observable collection.

public static IVirtualScrollAdapter CreateObservableCollectionAdapter<TSection, TItem>(ObservableCollection<TSection> collection, Func<TSection, ObservableCollection<TItem>> sectionItemsGetter)

Parameters

collection ObservableCollection<TSection>
sectionItemsGetter Func<TSection, ObservableCollection<TItem>>

Returns

IVirtualScrollAdapter

Type Parameters

TSection
TItem

CreateObservableCollectionAdapter<TSection, TItem>(ObservableCollection<TSection>, Func<TSection, ReadOnlyObservableCollection<TItem>>)

Creates a grouped virtual scroll adapter for the specified observable collection.

public static IVirtualScrollAdapter CreateObservableCollectionAdapter<TSection, TItem>(ObservableCollection<TSection> collection, Func<TSection, ReadOnlyObservableCollection<TItem>> sectionItemsGetter)

Parameters

collection ObservableCollection<TSection>
sectionItemsGetter Func<TSection, ReadOnlyObservableCollection<TItem>>

Returns

IVirtualScrollAdapter

Type Parameters

TSection
TItem

CreateObservableCollectionAdapter<TSection, TItem>(ReadOnlyObservableCollection<TSection>, Func<TSection, ObservableCollection<TItem>>)

Creates a grouped virtual scroll adapter for the specified observable collection.

public static IVirtualScrollAdapter CreateObservableCollectionAdapter<TSection, TItem>(ReadOnlyObservableCollection<TSection> collection, Func<TSection, ObservableCollection<TItem>> sectionItemsGetter)

Parameters

collection ReadOnlyObservableCollection<TSection>
sectionItemsGetter Func<TSection, ObservableCollection<TItem>>

Returns

IVirtualScrollAdapter

Type Parameters

TSection
TItem

CreateObservableCollectionAdapter<TSection, TItem>(ReadOnlyObservableCollection<TSection>, Func<TSection, ReadOnlyObservableCollection<TItem>>)

Creates a grouped virtual scroll adapter for the specified observable collection.

public static IVirtualScrollAdapter CreateObservableCollectionAdapter<TSection, TItem>(ReadOnlyObservableCollection<TSection> collection, Func<TSection, ReadOnlyObservableCollection<TItem>> sectionItemsGetter)

Parameters

collection ReadOnlyObservableCollection<TSection>
sectionItemsGetter Func<TSection, ReadOnlyObservableCollection<TItem>>

Returns

IVirtualScrollAdapter

Type Parameters

TSection
TItem

CreateStaticCollectionAdapter<T>(IEnumerable<T>)

Creates a virtual scroll adapter for the specified static collection.

public static IVirtualScrollAdapter CreateStaticCollectionAdapter<T>(IEnumerable<T> collection)

Parameters

collection IEnumerable<T>

Returns

IVirtualScrollAdapter

Type Parameters

T

CreateStaticCollectionAdapter<TSection, TItem>(IEnumerable<TSection>, Func<TSection, IEnumerable<TItem>>)

Creates a grouped virtual scroll adapter for the specified static collection.

public static IVirtualScrollAdapter CreateStaticCollectionAdapter<TSection, TItem>(IEnumerable<TSection> collection, Func<TSection, IEnumerable<TItem>> sectionItemsGetter)

Parameters

collection IEnumerable<TSection>
sectionItemsGetter Func<TSection, IEnumerable<TItem>>

Returns

IVirtualScrollAdapter

Type Parameters

TSection
TItem

GetGlobalFooterTemplate()

Gets the appropriate global footer template.

public DataTemplate? GetGlobalFooterTemplate()

Returns

DataTemplate

GetGlobalHeaderTemplate()

Gets the appropriate global header template.

public DataTemplate? GetGlobalHeaderTemplate()

Returns

DataTemplate

GetItemTemplate(object?)

Gets the appropriate item template for the given item.

public DataTemplate? GetItemTemplate(object? item)

Parameters

item object

Returns

DataTemplate

GetSectionFooterTemplate(object?)

Gets the appropriate section footer template for the given section.

public DataTemplate? GetSectionFooterTemplate(object? section)

Parameters

section object

Returns

DataTemplate

GetSectionHeaderTemplate(object?)

Gets the appropriate section header template for the given section.

public DataTemplate? GetSectionHeaderTemplate(object? section)

Parameters

section object

Returns

DataTemplate

GetVisibleItemsRange()

Gets the range of currently visible items in the virtual scroll.

public VirtualScrollRange? GetVisibleItemsRange()

Returns

VirtualScrollRange?

A VirtualScrollRange containing the first and last visible item positions, or null if no items are visible or the handler is not available.

OnHandlerChanged()

When overridden in a derived class, should raise the HandlerChanged event.

protected override void OnHandlerChanged()

Remarks

It is the implementor's responsibility to raise the HandlerChanged event.

ScrollTo(int, int, ScrollToPosition, bool)

Scrolls to the specified item in the virtual scroll.

public void ScrollTo(int sectionIndex, int itemIndex, ScrollToPosition position = ScrollToPosition.MakeVisible, bool animated = true)

Parameters

sectionIndex int

The index of the section.

itemIndex int

The index of the item within the section. Use -1 to scroll to the section header.

position ScrollToPosition

The position to scroll to. Defaults to MakeVisible.

animated bool

Whether the scroll should be animated. Defaults to true.

ScrollTo(object, ScrollToPosition, bool)

Scrolls to the specified item or section in the virtual scroll. This method searches through all sections and items to find the matching object.

public void ScrollTo(object itemOrSection, ScrollToPosition position = ScrollToPosition.MakeVisible, bool animated = true)

Parameters

itemOrSection object

The item or section object to scroll to.

position ScrollToPosition

The position to scroll to. Defaults to MakeVisible.

animated bool

Whether the scroll should be animated. Defaults to true.

Events

OnRefresh

Event raised when the user triggers a refresh.

public event EventHandler<RefreshEventArgs>? OnRefresh

Event Type

EventHandler<RefreshEventArgs>

OnScrolled

Event raised when the scroll position changes.

public event EventHandler<VirtualScrollScrolledEventArgs>? OnScrolled

Event Type

EventHandler<VirtualScrollScrolledEventArgs>