Repository navigation
Closed
Labels
area-controls-collectionviewCollectionView, CarouselView, IndicatorViewdelighterdelighter-scfixed-in-8.0.20fixed-in-9.0.0-preview.3.10457p/1Work that is important, and has been scheduled for release in this or an upcoming sprintplatform/androids/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working
Milestone
Description
Description
I have a CollectionView where ItemSizingStrategy is set to MeasureFirstItem. The properties of the times are changed some time of the CollectionView is loaded. Somehow, this makes some items become invisible on Android. It works fine on Windows.
Originally, my list looks like this:
Then, the two first items should be changed to green. But the second one just disappears:
In Windows it's works fine:
It's very strange :-)
Steps to Reproduce
- Create a new Maui app.
- Change
MainPage.xamlto:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:v="clr-namespace:MauiIssues"
x:Class="MauiIssues.MainPage"
>
<Grid>
<CollectionView ItemsSource="{Binding Issues}" ItemSizingStrategy="MeasureFirstItem">
<CollectionView.ItemTemplate>
<DataTemplate>
<Grid>
<Label Text="{Binding Title, Mode=OneWay}"
TextColor="Red"
IsVisible="{Binding IsRed}"
/>
<Label Text="{Binding Title, Mode=OneWay}"
TextColor="Green"
IsVisible="{Binding IsGreen}}"
/>
</Grid>
</DataTemplate>
</CollectionView.ItemTemplate>
</CollectionView>
</Grid>
</ContentPage>- Change
MainPage.csto:
using System.Collections.ObjectModel;
namespace MauiIssues;
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
BindingContext = this;
}
public class Issue : BindableObject
{
public string Title { get; set; }
public bool IsRed { get; set; } = true;
public bool IsGreen => !IsRed;
public void MakeGreen()
{
IsRed = false;
OnPropertyChanged(nameof(IsGreen));
OnPropertyChanged(nameof(IsRed));
}
}
public ObservableCollection<Issue> Issues { get; } = new ObservableCollection<Issue>();
protected async override void OnAppearing()
{
base.OnAppearing();
Issues.Add(new Issue { Title = "Issue 1" });
Issues.Add(new Issue { Title = "Issue 2" });
Issues.Add(new Issue { Title = "Issue 3" });
await Task.Delay(4000);
Issues[0].MakeGreen();
Issues[1].MakeGreen();
}
}Run the project in Android.
Full sample code: https://github.com/pekspro/MauiIssues/tree/7562_MeasureFirstItem_makes_items_disappear
Version with bug
6.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Windows 10.0.17763.0, Android 11
Did you find any workaround?
Removing ItemSizingStrategy="MeasureFirstItem" solves the problem.
Relevant log output
No response
Reacted by Shane Flynn, Jim Vakos, Edward Miller, Thomas Aa and AK
Reacted by mavispuford
Metadata
Metadata
Assignees
Labels
area-controls-collectionviewCollectionView, CarouselView, IndicatorViewdelighterdelighter-scfixed-in-8.0.20fixed-in-9.0.0-preview.3.10457p/1Work that is important, and has been scheduled for release in this or an upcoming sprintplatform/androids/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working
Type
Projects
- StatusShow more project fieldsDone



Activity
kristinx0211 commentedon May 30, 2022
can be reproduced on android 12 with above project.
ToolmakerSteve commentedon May 31, 2022
Certain UI changes in OnAppearing have always been unreliable in Xamarin.Forms. Perhaps the improvements for Maui have not helped avoid this "twilight zone".
Here, its those
OnPropertyChangedcalls that can't be relied on to take effect.It would be great to see this kind of issue fixed.
FWIW (work-around):
The 4 second delay shown there is useless; all that does is suspend maui's processing of the page. If you instead do
I'm sure it will work.
pekspro commentedon Nov 11, 2022
I've updated sample application to .NET 7. The same issue remains. I have also tried the work around from @ToolmakerSteve, but it didn't helped.
davidverriere commentedon Feb 7, 2023
Same issue here in .Net 7.0
symbiogenesis commentedon Feb 8, 2023
I'm seeing the same on Android, only. Using .NET 7 with the latest workloads.
XamlTest commentedon May 10, 2023
Verified this on Visual Studio Enterprise 17.6.0 Preview 7.0. Repro on Android 13.0, with below Project:
7562.zip
Android:

thomaskaelin commentedon Jun 7, 2023
I also noticed this issue while migrating an Xamarin.Forms-app to .NET MAUI. Any news on this?
19 remaining items
Zerachiel01 commentedon Mar 8, 2024
Please fix this. I'm even thinking of leaving MAUI and choosing another framework because of this and the performance loss without it.
PureWeen commentedon Mar 27, 2024
This should be fixed our nightlies
If anyone can test and let me know your results that would be super!
Can you test with the latest nightly build?
https://github.com/dotnet/maui/wiki/Nightly-Builds
filipleifer commentedon Apr 18, 2024
@PureWeen No still not working.