Skip to content
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

List goes blank after reset event #81

Closed
nielsenko opened this issue Sep 4, 2019 · 7 comments

Comments

@nielsenko
Copy link

commented Sep 4, 2019

When an item source raises a CollectionChanged event with action NotifyCollectionChangedAction.Reset, then _dataSource is simply cleared.

case NotifyCollectionChangedAction.Reset:
  _dataSource.Clear();
  parentView.GetRecycledViewPool().Clear();
  NotifyDataSetChanged();
  break;

Hence the list view goes blank, instead of actually re-evaluating the ItemsSource, at least for me.

Platform used during testing

  • OS: Android
  • Device: Nexus 5x, Honeywell EDA51
  • Sdk version: Android SDK 21+
  • Xamarin.Forms: 4.1.0-sr3
@roubachof roubachof added the bug label Sep 4, 2019
@roubachof roubachof added this to To do in Kanban board Sep 4, 2019
@roubachof

This comment has been minimized.

Copy link
Owner

commented Sep 4, 2019

I don't think I will support the semantic you gave about the Reset action (re-evaluating vs clearing), because:

  1. ObservableCollection only sends Reset action when the collection has been cleared.
protected override void ClearItems()
    {
      this.CheckReentrancy();
      base.ClearItems();
      this.OnCountPropertyChanged();
      this.OnIndexerPropertyChanged();
      this.OnCollectionReset();
    }
  1. Offical doc
Reset 4 The content of the collection was cleared.

If your ItemsSource changed a lot, just raise the property changed from your view model, and the view source / recycler adapter will be refreshed.

@roubachof roubachof moved this from To do to Done in Kanban board Sep 4, 2019
@roubachof roubachof added wontfix and removed bug labels Sep 5, 2019
@nielsenko

This comment has been minimized.

Copy link
Author

commented Sep 5, 2019

I think this actually changed with .NET 4.5. I'm old enough to remember different semantics for Reset, aka lots has happened, please re-evaluate your binding :-)

Anyway, fx DynamicData.Binding.ObservableCollectionExtended will simply raise a Reset after notification has been suspended. Similar using DynamicData.IObservable<IChangeSet<T>>.Bind has a resetThreshold argument (that defaults to 25) for how many changes to track before simply raising a reset event, instead of creating an storm of Adds, Removes etc. So to play nice with DynamicData you might consider to reconsider? I would love to be able to use it together with Sharpnado.

@nielsenko

This comment has been minimized.

Copy link
Author

commented Sep 5, 2019

I tried using your suggested workaround, ie. raising a PropertyChanged event on the property that ItemsSource is bound to, just after the CollectionChanged Reset event, but the control stays blank :-/

@roubachof roubachof added bug and removed wontfix labels Sep 5, 2019
@roubachof

This comment has been minimized.

Copy link
Owner

commented Sep 5, 2019

Ok you won :)
Since the old semantic is backward compatible with the new one.

@roubachof roubachof moved this from Done to In progress in Kanban board Sep 5, 2019
@roubachof roubachof moved this from In progress to Done in Kanban board Sep 5, 2019
@nielsenko

This comment has been minimized.

Copy link
Author

commented Sep 6, 2019

🙏 Thank you. Do you have a target date for your next release? No promises, just a vague idea?

@roubachof

This comment has been minimized.

Copy link
Owner

commented Sep 6, 2019

roubachof added a commit that referenced this issue Sep 11, 2019
@roubachof

This comment has been minimized.

Copy link
Owner

commented Sep 24, 2019

fixed in v1.3.0

@roubachof roubachof closed this Sep 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
2 participants
You can’t perform that action at this time.