CollectionView<TItem, TSection>

A data-driven list, grid, or carousel whose groups carry their own section model.
public class CollectionView<TItem, TSection> : View 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; }

EmptyView

Shown instead of the items while the source is empty.

Type: View?

public View? EmptyView { get; set; }

FooterTemplate

Builds a section footer. Bound to the section model.

Type: Func<ItemView<TSection>>?

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

GroupedItemsSource

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

Type: BindableList<TSection>

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

HeaderTemplate

Builds a section header. Bound to the section model.

Type: Func<ItemView<TSection>>?

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

HighlightColor

The tapped row's highlight color, or null for the system gray.

Type: Color?

public Color? HighlightColor { get; set; }

HighlightsSelection

Whether a tapped row shows a highlight until the page is next appeared.

Type: bool

public bool HighlightsSelection { 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: IReadOnlyList<string>?

public IReadOnlyList<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; }

ItemsSource

The items to show.

Changes animate into place when the list is an ObservableCollection.

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; }

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; }

Scrolled

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

Type: Action<double>?

public Action<double>? Scrolled { 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 one ItemTemplate.

Type: Func<TSection, CollectionLayout>?

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

SelectedItems

The items checked while editing.

Give it an ObservableCollection: taps keep it in sync, and mutating it moves the checkmarks.

Type: BindableList<TItem>

public BindableList<TItem> SelectedItems { 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; }

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 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.