-
Notifications
You must be signed in to change notification settings - Fork 1.9k
CollectionView.EmptyView does not remeasure its height when the parent layout changes dynamically, causing incorrect sizing. #33324
Description
Description
CollectionView.EmptyView does not remeasure its height when the parent layout changes dynamically, causing incorrect sizing.
Steps to Reproduce
Steps to Reproduce
-
Create a page with two
CollectionViewcontrols in a vertical layout:- First CollectionView: Initially hidden with
IsVisible="{Binding HasItems}" - Second CollectionView: Below the first, displays EmptyView with custom content (e.g., a Grid with background and Label)
- First CollectionView: Initially hidden with
-
Initial state: First CollectionView is hidden (no items), second CollectionView shows EmptyView with full available height
-
Load data: First CollectionView receives items and becomes visible, pushing the second CollectionView down
-
Bug: The second CollectionView adjusts its position and overall height correctly, but its EmptyView content retains the original height from step 2, not remeasuring to fit the new available space
Expected Behavior
When the parent layout changes and available space decreases, the EmptyView should remeasure and resize its content to fit the new constraints.
Actual Behavior
The EmptyView retains its original measured height even after the parent layout changes, resulting in content that doesn't fit the new available space.
Basic Information
- Version: .NET 10.0 / Microsoft.Maui.Controls 10.0.20
- Platform: Android (issue may affect other platforms)
- Affected control:
CollectionView.EmptyView
Code Sample
<Grid RowDefinitions="Auto,*" RowSpacing="20">
<VerticalStackLayout>
<!-- First CollectionView - becomes visible when data loads -->
<VerticalStackLayout IsVisible="{Binding HasGames}">
<CollectionView ItemsSource="{Binding MyGames}" MaximumHeightRequest="300">
<!-- ItemTemplate -->
</CollectionView>
</VerticalStackLayout>
</VerticalStackLayout>
<!-- Second CollectionView - EmptyView doesn't remeasure -->
<CollectionView Grid.Row="1" ItemsSource="{Binding Players}">
<CollectionView.EmptyView>
<Grid>
<local:CustomBackground />
<Label Text="No players" HorizontalOptions="Center" VerticalOptions="Center" />
</Grid>
</CollectionView.EmptyView>
</CollectionView>
</Grid>Link to public reproduction project repository
No response
Version with bug
10.0.20
Is this a regression from previous behavior?
Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 16
Did you find any workaround?
nope