CollectionView<TItem, TSection>

A data-driven list, grid, or carousel whose groups carry their own section model.
public class CollectionView<TItem, TSection> : Container where TItem : class where TSection : class, ISection<TItem>
Type parameterSummary
(class) TItemThe item type.
ISection<TItem> TSectionThe section model the header and footer templates bind to.

Properties

AvoidsKeyboard

Whether the collection is inset so the keyboard never covers its content.

Type: bool

public bool AvoidsKeyboard { get; set; }

DefaultScrollPosition

Where the collection starts after its first nonempty layout, and where a system scroll-to-top gesture (status bar, the selected tab, or the navigation bar) lands.

The default is ScrollPosition.Top. Set it to ScrollPosition.Bottom for content whose newest entry is at the end, such as a calendar or a chat.

Type: ScrollPosition

public ScrollPosition DefaultScrollPosition { get; set; }

EmptyView

Shown instead of the items while the source is empty.

Type: View?

public View? EmptyView { get; set; }

One view below every section. It scrolls with the collection.

Type: View?

public View? Footer { get; set; }

GroupedItemsSource

Groups, each with its own header. Takes precedence over ItemsSource.

Use IVirtualizedSectionList<TItem, TSection> when section counts and items should be produced without first creating every section model.

Type: BindableList<TSection>

public BindableList<TSection> GroupedItemsSource { get; set; }

One view above every section. It scrolls with the collection unless PinsHeader is enabled.

Type: View?

public View? Header { get; set; }

IndexTitles

Explicit labels for the fast-scroll index, or null to show one per section.

A tapped letter with no section jumps to the nearest one at or after it.

Has no effect without SectionIndexTitle, which still supplies each section's letter.

Type: BindableList<string>

public BindableList<string> IndexTitles { get; set; }

IsEditing

Whether the collection is in edit mode, showing selection circles and reorder handles.

Type: Bindable<bool>

public Bindable<bool> IsEditing { get; set; }

IsRefreshing

Whether the refresh spinner is showing.

With a two-way binding, pulling sets it to true and the ViewModel sets it to false when done.

Type: Bindable<bool>

public Bindable<bool> IsRefreshing { get; set; }

ItemCommand

Command invoked with the tapped item.

Type: ICommand?

public ICommand? ItemCommand { get; set; }

ItemContextMenu

Entries in a row's long-press context menu.

Each command is invoked with the row's item.

Type: IList<MenuAction>

public IList<MenuAction> ItemContextMenu { get; }

ItemPreview

Builds the floating preview shown over a row's context menu, given the row's item.

Without it the row itself is the preview.

Type: Func<TItem, View>?

public Func<TItem, View>? ItemPreview { get; set; }

ItemTemplate

Builds the element tree for a cell. Called once per recycled cell, never per item.

Type: Func<ItemView<TItem>>?

public Func<ItemView<TItem>>? ItemTemplate { get; set; }

ItemTemplateSelector

Chooses a strongly typed cell template from each item's runtime type.

Takes precedence over ItemTemplate. Register every concrete runtime item type before the collection is realized.

Type: ItemTemplateSelector<TItem>?

public ItemTemplateSelector<TItem>? ItemTemplateSelector { get; set; }

ItemsSource

The items to show.

Changes animate into place when the list is an ObservableCollection. An IVirtualizedList<TItem> is read directly by index without creating a snapshot.

Type: BindableList<TItem>

public BindableList<TItem> ItemsSource { get; set; }

KeyboardDismiss

How dragging the collection dismisses the keyboard.

Type: KeyboardDismiss

public KeyboardDismiss KeyboardDismiss { get; set; }

Layout

How the items are arranged.

Type: CollectionLayout

public CollectionLayout Layout { get; set; }

LoadMoreCommand

Invoked when the user scrolls within LoadMoreThreshold items of the end.

Fires once per item count.

Type: ICommand?

public ICommand? LoadMoreCommand { get; set; }

LoadMoreCommandParameter

The parameter passed to LoadMoreCommand.

Type: object?

public object? LoadMoreCommandParameter { get; set; }

LoadMoreThreshold

How many items from the end LoadMoreCommand fires at.

Type: int

public int LoadMoreThreshold { get; set; }

PinsHeader

Keeps Header visible at the collection's top edge while its content scrolls beneath it.

Type: bool

public bool PinsHeader { get; set; }

Prefetch

Maps an item to the image url to warm before its row scrolls on.

Setting it enables prefetching through the app's image loader.

Type: Func<TItem, string?>?

public Func<TItem, string?>? Prefetch { get; set; }

PreviewCommand

Invoked with the row's item when its context-menu preview is tapped.

Type: ICommand?

public ICommand? PreviewCommand { get; set; }

PreviewShape

Shapes the row itself as the lifted platter: padding around the content and a corner radius.

Null keeps the system shape.

Type: PreviewShape?

public PreviewShape? PreviewShape { get; set; }

RefreshCommand

Command invoked when the user pulls to refresh.

Setting it installs the refresh control. The ICommand.CanExecute controls whether the user can pull to refresh.

Type: ICommand?

public ICommand? RefreshCommand { get; set; }

RefreshCommandParameter

The parameter passed to RefreshCommand.

Type: object?

public object? RefreshCommandParameter { get; set; }

ReorderCommand

Invoked after a drag-to-reorder with an ItemMove<TItem>.

Setting it enables a long-press drag, unless a context menu owns that gesture; the edit-mode handle always drags.

The move is already applied to the source when it fires.

Type: ICommand?

public ICommand? ReorderCommand { get; set; }

RetainsHighlight

Whether a highlighted row keeps its background until the page next appears.

The row appearance is defined by ItemView<TItem>.HighlightBackground. With a selection binding a false value still shows the selection checkmark; only the background is released.

Type: bool

public bool RetainsHighlight { get; set; }

Scrolled

Invoked as the collection scrolls, with the vertical offset in points.

Type: Action<double>?

public Action<double>? Scrolled { get; set; }

SectionFooterTemplate

Builds a footer for each section. Bound to the section model.

Type: Func<ItemView<TSection>>?

public Func<ItemView<TSection>>? SectionFooterTemplate { get; set; }

SectionHeaderTemplate

Builds a header for each section. Bound to the section model.

Type: Func<ItemView<TSection>>?

public Func<ItemView<TSection>>? SectionHeaderTemplate { get; set; }

SectionIndexTitle

Maps a section to its letter in the fast-scroll index, or null for no index.

Grouped list layouts only. Tapping a letter jumps to that section.

Type: Func<TSection, string>?

public Func<TSection, string>? SectionIndexTitle { get; set; }

SectionLayout

Gives each section its own layout, or null to arrange every section with Layout.

Mixes arrangements in one collection, like a carousel row above a list. Every section shares the configured item template or selector.

Type: Func<TSection, CollectionLayout>?

public Func<TSection, CollectionLayout>? SectionLayout { get; set; }

SelectedItem

The selected item in single-selection mode, or null for no selection.

Binding it enables single selection: taps replace the selection, and a two-way binding pushes the tapped item to the source. Use SelectsOnlyWhileEditing to keep normal taps as activation. Bind either this or SelectedItems, never both.

Type: Bindable<TItem?>

public Bindable<TItem?> SelectedItem { get; set; }

SelectedItems

The selected items in multiple-selection mode, or null for no selection.

Binding it enables multiple selection: taps toggle rows, and mutating the bound collection moves the selection. Give it an ObservableCollection so taps can write back. Use SelectsOnlyWhileEditing to keep normal taps as activation. Bind either this or SelectedItem, never both.

Type: BindableList<TItem>

public BindableList<TItem> SelectedItems { get; set; }

SelectsOnlyWhileEditing

Whether taps change the selection only while editing. Defaults to false.

When true, normal taps only activate: ItemCommand runs and the transient highlight behaves as if no selection were bound. Edit mode selects with the shape of SelectedItem or SelectedItems.

Type: bool

public bool SelectsOnlyWhileEditing { get; set; }

SeparatorInsets

Leading/trailing insets for the separator lines, or null for the system default.

List layouts only.

Type: Thickness?

public Thickness? SeparatorInsets { get; set; }

ShowsIndicator

Whether the scroll indicator is shown.

Type: bool

public bool ShowsIndicator { get; set; }

ShowsSelectionCheckmark

Whether selected rows show a trailing checkmark drawn by the collection.

Type: bool

public bool ShowsSelectionCheckmark { get; set; }

ShowsSeparators

Whether rows draw their separator lines.

List layouts only.

Type: bool

public bool ShowsSeparators { get; set; }

SwipeActions

Actions revealed by swiping a row.

List layouts only.

Type: IList<SwipeAction>

public IList<SwipeAction> SwipeActions { get; }

Methods

MeasureOverride

Content measurement. Panels recurse; controls delegate to the native SizeThatFits.

protected override Size MeasureOverride(
  Size availableSize)
ParameterSummary
Size availableSizeThe size available for the view's content.

Returns

  • Size: The desired content size.

ScrollTo

Scrolls to the beginning, middle, or end of the collection's content.

public void ScrollTo(
  ScrollPosition position,
  bool animated = true)
ParameterSummary
ScrollPosition positionThe content position to reveal.
(optional) bool animatedWhether the scroll is animated.

ScrollTo

Scrolls the list until item is visible, aligned to the given viewport edge.

public void ScrollTo(
  TItem item,
  ScrollPosition position = Top,
  bool animated = true)
ParameterSummary
TItem itemThe item to bring into view.
(optional) ScrollPosition positionThe viewport edge the item aligns to.
(optional) bool animatedWhether the scroll is animated.

ScrollTo

Scrolls an indexed item into view.

public void ScrollTo(
  int section,
  int item,
  ScrollPosition position = Top,
  bool animated = true)
ParameterSummary
int sectionThe zero-based section index.
int itemThe zero-based item index within the section.
(optional) ScrollPosition positionWhere the item lands in the viewport.
(optional) bool animatedWhether the scroll is animated.