Skip to content

[Mac Catalyst] BindableLayout in ContentView only renders first item when BindingContext set after InitializeComponent #34499

@rmarinho

Description

@rmarinho

Description

When a ContentView's BindingContext is set in code-behind after InitializeComponent(), a BindableLayout.ItemsSource="{Binding Items}" inside that ContentView only renders the first item from an ObservableCollection on Mac Catalyst. The collection reports the correct count, but only 1 of N items appears in the visual tree.

Steps to Reproduce

  1. Clone the repro: https://github.com/rmarinho/bindable-layout-repro
  2. Run on Mac Catalyst: dotnet build -f net11.0-maccatalyst -t:Run
  3. Observe the "Items from BindableLayout" section — only 1 item renders instead of 5

Repro structure:

  • ItemListView.xaml — A ContentView with BindableLayout.ItemsSource="{Binding Items}" and an ItemTemplate
  • ItemListViewModel.cs — Has ObservableCollection<string> with 5 items in the collection initializer
  • MainPage.xaml.cs — Sets BuggyList.BindingContext = viewModel after InitializeComponent()

Expected Behavior

All 5 items from the ObservableCollection should render in the VerticalStackLayout via BindableLayout.

The {Binding Items.Count, StringFormat='Total items: {0}'} label correctly shows "Total items: 5", confirming the binding resolves and the collection has all items — but only 1 item is rendered.

Actual Behavior

Only the first item ("Item 1 - Apple") renders. The remaining 4 items are not present in the visual tree.

Additionally:

  • Dynamically adding items to the ObservableCollection after initial load also does not render
  • The binding itself resolves (proven by Items.Count binding showing correct value)
  • The issue appears specific to BindableLayout inside a ContentView when BindingContext is set post-initialization

Workaround

Call BindableLayout.SetItemsSource() directly in code-behind instead of using XAML binding:

// Instead of: BuggyList.BindingContext = viewModel;
// (which relies on BindableLayout.ItemsSource="{Binding Items}" in XAML)

// Use:
BindableLayout.SetItemsSource(myLayout, viewModel.Items);

The repro project includes both the buggy scenario (blue items, only 1 renders) and the workaround (green items, all 5 render correctly).

Reproduction Link

https://github.com/rmarinho/bindable-layout-repro

Version with bug

10.0.41 SR1 / 11.0-preview

Is this a regression from previous behavior?

Unknown — first encountered on Mac Catalyst with .NET 10

Last version that worked well

No response

Affected platforms

macOS (Mac Catalyst)

Affected platform versions

macOS 15.x (Sequoia)

Did you find any workaround?

Yes — call BindableLayout.SetItemsSource(layout, collection) directly in code-behind instead of using XAML BindableLayout.ItemsSource="{Binding ...}".

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    platform/macosmacOS / Mac Catalysts/triagedIssue has been reviewedt/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions