Skip to content

ListView: support <ListView.stickyHeaderTemplate> element #11697

Done

Description

@liuy97

Is your feature request related to a problem? Please describe.

ListView.stickyHeaderTemplate only works reliably as an inline XML string attribute:

<ListView items="{{ items }}" sectioned="true" stickyHeader="true"
          stickyHeaderTemplate="<Label text='{{ title }}' />">

Long or nested header layouts are awkward to write in an escaped attribute string. The natural way to write them, the same way itemTemplate works, fails:

<ListView items="{{ items }}" sectioned="true" stickyHeader="true">
  <ListView.stickyHeaderTemplate>
    <StackLayout class="section-header">
      <Label text="{{ title }}" />
    </StackLayout>
  </ListView.stickyHeaderTemplate>

  <ListView.itemTemplate>
    <Label text="{{ name }}" />
  </ListView.itemTemplate>
</ListView>

Current behavior:

  • iOS: show empty label.
  • Android: each header shows a generic Section N label instead of the template.

stickyHeaderTemplate is not registered in Builder.knownTemplates, which only contains itemTemplate.

A function template has a related gap. The property is typed string | Template, but Android only handles strings. A function template set in code or by a framework renderer (Angular/Vue/Svelte via UI_USE_EXTERNAL_RENDERER) is ignored on Android, while it works on iOS.

Describe the solution you'd like

Make stickyHeaderTemplate a first-class template, like itemTemplate:

  1. Add 'stickyHeaderTemplate' to Builder.knownTemplates so the element form <ListView.stickyHeaderTemplate> yields a Template factory.
  2. Resolve the header view in one shared ListViewBase helper used by both platforms. Builder.parse(value, context) already handles both an XML string and a Template function. If no template is given, or it fails to build, fall back to a Section N label.
  3. Support all three forms on both iOS and Android:
    • an inline string attribute;
    • a <ListView.stickyHeaderTemplate> element;
    • a Template function set in code or by external renderers.

Describe alternatives you've considered

  • Keep using the inline string attribute. This works, but it's hard to read and maintain for anything beyond a single Label. It also needs escaped quotes and offers no editor support.
  • Set a function template in code-behind. This works on iOS only; Android ignores it.

Anything else?

  • The property is already declared as string | Template in packages/core/ui/list-view/index.d.ts, so this aligns the runtime behavior with the public type. It doesn't add new API.
  • KeyedTemplate ({ key, createView }) is out of scope, since a single header template has no use for a key.

Please accept these terms

Activity

  1. added
    feature-pending-triage
    on Dec 1, 2026
  2. added a commit that references this issue on Dec 3, 2026
    327e227
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-pending-triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions