-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when adding to ObservableCollection #21374
Comments
Verified this issue with Visual Studio 17.10.0 Preview 2&17.6.10 build 428. Not repro on iOS platform with sample project. |
I get this error in 8.0.10 and in 8.0.14 too. Worked well in 8.0.7. The workaround is not working for me in my project (changing * to Auto). |
Issue is still present in 8.0.20-nightly.10336+sha.d03a2c66aa-azdo.9265184 |
@mooola on your sample why do you have the WidthRequest on the border set to 0.5? https://github.com/mooola/MauiIssues/blob/main/MauiApp3/MainPage.xaml#L36 If I set that border to something like 100 then I don't get the exception. |
@PureWeen - I created the sample exactly how we found it in our app. I don't have an explanation as to why it is set to 0.5, but in our project when we removed that property entirely, we didn't get the exception. When we tried removing the property in our sample, we still got the exception so I didn't mention it. We are seeing this issue on multiple CollectionViews in our app. One that is contained in grids, doesn't have a border with a WidthRequests. |
Something else we found was changing how the ObservableCollection was populated didn't cause the error. private void PopulatePerson(object parameter)
{
IsPersonVisible = true;
try
{
List<Person> people = new List<Person>();
for (int j = 0; j < 10; j++)
{
people.Add(new Person { Name = "Person " + j });
}
People = new ObservableCollection<Person>(people);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
} |
More info, cannot reproduce it on Catalyst. |
|
This workaround seems the same of these similar issues, maybe the problem affects more platforms? |
It's fairly platform independent why this would be causing issues. |
Can you include a sample where this is crashing, and you aren't setting the Width to zero? As far as we can tell this exception is fairly limited to scenarios where the CoillectionView is measuring to a zero width which is causing a strange invalidation to happen. We could throw a couple things in that seem to avoid the crash, but I worry those are only fixing symptoms and you'll still get crashes for your other scenarios. |
For me, setting ItemSizingStrategy="MeasureFirstItem" on the CollectionView resolves the issue. Just as mentioned in this old bug report for Xamarin: xamarin/Xamarin.Forms#13323 |
Description
Immediately after upgrading to Maui Controls 8.0.0.10, we have been getting an error when adding items to ObservableCollection
Steps to Reproduce
Link to public reproduction project repository
https://github.com/mooola/MauiIssues
Version with bug
8.0.10 SR3
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI
Last version that worked well
8.0.7 SR2
Affected platforms
iOS
Affected platform versions
No response
Did you find any workaround?
Changing line 40 in MainPage.xaml to Auto "fixes" the issue.
Relevant log output
No response
The text was updated successfully, but these errors were encountered: