DynamicData: [Bug]: Unexpected "Reset" Action in CollectionChanged Event When Adding data to ReadOnlyObservableCollection from SourceList
Describe the bug π
When binding a DynamicData.SourceList to a ReadOnlyObservableCollection in a WPF application, and then adding data to the SourceList, the e.Action property in the CollectionChanged event of the ReadOnlyObservableCollection is reported as βResetβ instead of βAdd.β However, when adding a data again to the SourceList, the e.Action property is reported as βAddβ.
Code snippet: Properties:
private readonly SourceList<Person> _parentsSource = new SourceList<Person>();
public ReadOnlyObservableCollection<Person> Parents
{
get;
}
Codes:
_parentsSource.Connect()
.ObserveOn(RxApp.MainThreadScheduler)
.Bind(out var parents)
.Subscribe();
Parents = parents;
(Parents as INotifyCollectionChanged).CollectionChanged += MainWindow_CollectionChanged;
Button click codes:
private void AddADataButton_Click(object sender, RoutedEventArgs e)
{
var data = new Person() { FirstName = "Data", LastName = "Data"};
_parentsSource.Add(data);
}
Step to reproduce
- Run the sample.
- Click the βADDβ button.
- Ensure the Action property value shown in the MessageBox [i.e., βResetβ].
- Again click the βADDβ button.
- Ensure the Action property value shown in the MessageBox [i.e.,βAddβ].
Reproduction repository
NA
Expected behavior
The e.Action property in the CollectionChanged event of the ReadOnlyObservableCollection should be reported as βAddβ when adding an item to the SourceList.
Screenshots πΌοΈ
When adding the data for the first time.
When adding the data for second time.
I have attached the sample for the replication.
ReadOnlyObservableCollection_SimpleSample.zip
IDE
Visual Studio 2022
Operating system
Windows
Version
No response
Device
No response
DynamicData Version
8.1.1
Additional information βΉοΈ
No response
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 17
Iβve introduced changes (not deployed yet) which allows the control of reset operations in dynamic data.
I have introduced code which enables binding to be turned off
and it seems to fix the issue. Annoyingly I have to grab a free trial of Synch Fusion to test!
See description of this https://github.com/reactivemarbles/DynamicData/pull/776 for more details. It will be released soon.
BTW I advise not to turn off reset threshold system wide as it is a seriously important performance optimisier
I think the problem with introducing more libraries is it could explode into way more than we wish to maintain. Whereas keeping it as a single library is comparatively simple.