From 7ad977ffca03b5608d1c05beaff4453d6e485c96 Mon Sep 17 00:00:00 2001 From: neuecc Date: Wed, 4 Sep 2024 10:40:04 +0900 Subject: [PATCH] support Range for ToNotifyCollectionChanged #67 --- README.md | 4 + sandbox/AvaloniaApp/MainWindow.axaml | 11 ++- sandbox/AvaloniaApp/MainWindow.axaml.cs | 58 ++++++++++-- sandbox/WpfApp/MainWindow.xaml | 2 + sandbox/WpfApp/MainWindow.xaml.cs | 22 ++++- .../AlternateIndexList.cs | 4 +- .../ObservableList.OptimizeView.cs | 10 ++- .../SynchronizedViewList.cs | 88 ++++++++++++++++--- 8 files changed, 168 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 761ccca..21cf6b9 100644 --- a/README.md +++ b/README.md @@ -355,6 +355,10 @@ public class WpfDispatcherCollection(Dispatcher dispatcher) : ICollectionEventDi } ``` +`ToNotifyCollectionChanged()` can also be called without going through a View. In this case, it's guaranteed that no filters will be applied, making it faster. If you want to apply filters, please generate a View before calling it. Additionally, `ObservableList` has a variation called `ToNotifyCollectionChangedSlim()`. This option doesn't generate a list for the View and shares the actual data, making it the fastest and most memory-efficient option. However, range operations such as `AddRange`, `InsertRange` and `RemoveRange` are not supported by WPF (or Avalonia), so they will throw runtime exceptions. + +Views and ToNotifyCollectionChanged are internally connected by events, so they need to be `Dispose` to release those connections. + Unity --- In Unity projects, you can installing `ObservableCollections` with [NugetForUnity](https://github.com/GlitchEnzo/NuGetForUnity). If R3 integration is required, similarly install `ObservableCollections.R3` via NuGetForUnity. diff --git a/sandbox/AvaloniaApp/MainWindow.axaml b/sandbox/AvaloniaApp/MainWindow.axaml index cfd3b92..9530d9b 100644 --- a/sandbox/AvaloniaApp/MainWindow.axaml +++ b/sandbox/AvaloniaApp/MainWindow.axaml @@ -7,7 +7,14 @@ Title="AvaloniaApp"> -