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
FadingEdgeLengthProperty
Bindable property for FadingEdgeLength.
public static readonly BindableProperty FadingEdgeLengthProperty
Field Value
FooterTemplateProperty
Bindable property for FooterTemplate.
public static readonly BindableProperty FooterTemplateProperty
Field Value
HeaderTemplateProperty
Bindable property for HeaderTemplate.
public static readonly BindableProperty HeaderTemplateProperty
Field Value
IsRefreshEnabledProperty
Bindable property for IsRefreshEnabled.
public static readonly BindableProperty IsRefreshEnabledProperty
Field Value
IsRefreshingProperty
Bindable property for IsRefreshing.
public static readonly BindableProperty IsRefreshingProperty
Field Value
ItemTemplateProperty
Bindable property for ItemTemplate.
public static readonly BindableProperty ItemTemplateProperty
Field Value
ItemsLayoutProperty
Bindable property for ItemsLayout.
public static readonly BindableProperty ItemsLayoutProperty
Field Value
RefreshAccentColorProperty
Bindable property for RefreshAccentColor.
public static readonly BindableProperty RefreshAccentColorProperty
Field Value
RefreshCommandProperty
Bindable property for RefreshCommand.
public static readonly BindableProperty RefreshCommandProperty
Field Value
ScrolledCommandProperty
Bindable property for ScrolledCommand.
public static readonly BindableProperty ScrolledCommandProperty
Field Value
SectionFooterTemplateProperty
Bindable property for SectionFooterTemplate.
public static readonly BindableProperty SectionFooterTemplateProperty
Field Value
SectionHeaderTemplateProperty
Bindable property for SectionHeaderTemplate.
public static readonly BindableProperty SectionHeaderTemplateProperty
Field Value
Properties
Adapter
The adapter that provides data to the virtual scroll.
public object? Adapter { get; set; }
Property Value
FadingEdgeLength
Gets or sets the length of the fading edge effect in device-independent units.
public double FadingEdgeLength { get; set; }
Property Value
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
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
IsRefreshEnabled
Gets or sets a value indicating whether pull-to-refresh is enabled.
public bool IsRefreshEnabled { get; set; }
Property Value
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
ItemTemplate
Gets or sets the template used to display each item.
public DataTemplate? ItemTemplate { get; set; }
Property Value
ItemsLayout
Gets or sets the layout for the virtual scroll.
public IVirtualScrollLayout ItemsLayout { get; set; }
Property Value
RefreshAccentColor
Gets or sets the accent color for the refresh indicator.
public Color? RefreshAccentColor { get; set; }
Property Value
RefreshCommand
Gets or sets the command to execute when the user requests a refresh.
public ICommand? RefreshCommand { get; set; }
Property Value
ScrolledCommand
Gets or sets the command to execute when the scroll position changes.
public ICommand? ScrolledCommand { get; set; }
Property Value
SectionFooterTemplate
Gets or sets the template used to display section footers.
public DataTemplate? SectionFooterTemplate { get; set; }
Property Value
SectionHeaderTemplate
Gets or sets the template used to display section headers.
public DataTemplate? SectionHeaderTemplate { get; set; }
Property Value
Methods
CreateObservableCollectionAdapter<T>(ObservableCollection<T>)
Creates a virtual scroll adapter for the specified observable collection.
public static IVirtualScrollAdapter CreateObservableCollectionAdapter<T>(ObservableCollection<T> collection)
Parameters
collectionObservableCollection<T>
Returns
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
collectionReadOnlyObservableCollection<T>
Returns
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
collectionObservableCollection<TSection>sectionItemsGetterFunc<TSection, ObservableCollection<TItem>>
Returns
Type Parameters
TSectionTItem
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
collectionObservableCollection<TSection>sectionItemsGetterFunc<TSection, ReadOnlyObservableCollection<TItem>>
Returns
Type Parameters
TSectionTItem
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
collectionReadOnlyObservableCollection<TSection>sectionItemsGetterFunc<TSection, ObservableCollection<TItem>>
Returns
Type Parameters
TSectionTItem
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
collectionReadOnlyObservableCollection<TSection>sectionItemsGetterFunc<TSection, ReadOnlyObservableCollection<TItem>>
Returns
Type Parameters
TSectionTItem
CreateStaticCollectionAdapter<T>(IEnumerable<T>)
Creates a virtual scroll adapter for the specified static collection.
public static IVirtualScrollAdapter CreateStaticCollectionAdapter<T>(IEnumerable<T> collection)
Parameters
collectionIEnumerable<T>
Returns
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
collectionIEnumerable<TSection>sectionItemsGetterFunc<TSection, IEnumerable<TItem>>
Returns
Type Parameters
TSectionTItem
GetGlobalFooterTemplate()
Gets the appropriate global footer template.
public DataTemplate? GetGlobalFooterTemplate()
Returns
GetGlobalHeaderTemplate()
Gets the appropriate global header template.
public DataTemplate? GetGlobalHeaderTemplate()
Returns
GetItemTemplate(object?)
Gets the appropriate item template for the given item.
public DataTemplate? GetItemTemplate(object? item)
Parameters
itemobject
Returns
GetSectionFooterTemplate(object?)
Gets the appropriate section footer template for the given section.
public DataTemplate? GetSectionFooterTemplate(object? section)
Parameters
sectionobject
Returns
GetSectionHeaderTemplate(object?)
Gets the appropriate section header template for the given section.
public DataTemplate? GetSectionHeaderTemplate(object? section)
Parameters
sectionobject
Returns
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
nullif 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
sectionIndexintThe index of the section.
itemIndexintThe index of the item within the section. Use -1 to scroll to the section header.
positionScrollToPositionThe position to scroll to. Defaults to MakeVisible.
animatedboolWhether 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
itemOrSectionobjectThe item or section object to scroll to.
positionScrollToPositionThe position to scroll to. Defaults to MakeVisible.
animatedboolWhether 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
OnScrolled
Event raised when the scroll position changes.
public event EventHandler<VirtualScrollScrolledEventArgs>? OnScrolled