maui
maui copied to clipboard
CollectionView Crash when clearing & adding data second time.
Description
See: https://github.com/dotnet-presentations/dotnet-maui-workshop/issues/49
Steps to Reproduce
1.) Open https://github.com/dotnet-presentations/dotnet-maui-workshop "Finish folder" 2.) Launch on iOS 3.) Load monkeys 4.) Load Monkeys again -> crash
Version with bug
Release Candidate 3 (current)
Last version that worked well
Unknown/Other
Affected platforms
iOS, macOS
Affected platform versions
iOS and possibly Mac (all versions)
Did you find any workaround?
not yet ;(
Relevant log output
No response
I fail to retrieve data from https://www.montemagno.com/monkeys.json, so I comment your Online code and use the offline part.
not repro with vs main build(32519.297.main)
I believe this is the same issue I experienced here: https://github.com/dotnet/maui/issues/7237
Happened to me too, but only in a Grouped CollectionView
A possible workaround is to use an ObservableProperty on a regular List and replace the entire object with each update, instead of using an ObservableCollection.
For example:
[INotifyPropertyChanged]
public partial class MainViewModel
{
[ObservableProperty]
List<Monkey> monkeys = new();
[RelayCommand]
void ReloadMonkeys()
{
List<Monkey> newMonkeys = Monkeys is null ? new() : new(Monkeys);
newMonkeys.Add(new("A1"));
newMonkeys.Add(new("A2"));
newMonkeys.Add(new("A3"));
Monkeys = newMonkeys;
}
}
instead of:
public partial class MainViewModel
{
public ObservableCollection<Monkey> Monkeys { get; } = new();
[RelayCommand]
void ReloadMonkeys()
{
Monkeys.Add(new("A1"));
Monkeys.Add(new("A2"));
Monkeys.Add(new("A3"));
}
}
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
Hi @jamesmontemagno. We have added the "s/try-latest-version" label to this issue, which indicates that we'd like you to try and reproduce this issue on the latest available public version. This can happen because we think that this issue was fixed in a version that has just been released, or the information provided by you indicates that you might be working with an older version.
You can install the latest version by installing the latest Visual Studio (Preview) with the .NET MAUI workload installed. If the issue still persists, please let us know with any additional details and ideally a reproduction project provided through a GitHub repository.
This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
Verified this issue with Visual Studio Enterprise 17.6.0 Preview 6.0, Not repro on iOS platform with above project.
dotnet-maui-workshop-main.zip