Pylon.ObservableList 1.0.0-beta-00001

This is a prerelease version of Pylon.ObservableList.
dotnet add package Pylon.ObservableList --version 1.0.0-beta-00001
                    
NuGet\Install-Package Pylon.ObservableList -Version 1.0.0-beta-00001
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Pylon.ObservableList" Version="1.0.0-beta-00001" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pylon.ObservableList" Version="1.0.0-beta-00001" />
                    
Directory.Packages.props
<PackageReference Include="Pylon.ObservableList" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Pylon.ObservableList --version 1.0.0-beta-00001
                    
#r "nuget: Pylon.ObservableList, 1.0.0-beta-00001"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Pylon.ObservableList@1.0.0-beta-00001
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Pylon.ObservableList&version=1.0.0-beta-00001&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Pylon.ObservableList&version=1.0.0-beta-00001&prerelease
                    
Install as a Cake Tool

Pylon.ObservableList

ObservableList<T> is a simple, extensible list that emits INotifyCollectionChanged events for each mutable operation. If you find ObservableCollection<T> or AvaloniaList<T> incomplete for your use case, consider using and extending ObservableList<T> with your own custom operations.

Getting Started

Install the Pylon.ObservableList package.

dotnet add package Pylon.ObservableList

Compatibility

ObservableList<T> is intended to be used with Avalonia and is compatible with the mutable operations of AvaloniaList<T>. However, it should be usable with any INotifyCollectionChanged consumers. Listed below is the comparison between the mutable operations of each list.

ObservableList<T> AvaloniaList<T>
Add(T) Add(T)
AddRange(IEnumerable<T>) AddRange(IEnumerable<T>)
Clear() Clear()
Insert(int, T) Insert(int, T)
InsertRange(int, IEnumerable<T>) InsertRange(int, IEnumerable<T>)
Move(int int) Move(int int)
MoveRange(int, int, int) MoveRange(int, int, int)
Remove(T) Remove(T)
RemoveAll(IEnumerable<T>) RemoveAll(IEnumerable<T>)
RemoveAt(int) RemoveAt(int)
RemoveRange(int, int) RemoveRange(int, int)
this[int] this[int]
Reverse()
Reverse(int, int)
RotateLeft(int)
RotateLeft(int, int, int)
RotateRight(int)
RotateRight(int, int, int)

Extending ObservableList<T>

ObservableList<T> exposes both the underlying Items list and methods for publishing INotifyCollectionChanged events. The example below demonstrates how to extend ObservableList<T> with custom operations.

public static class ObservableListExtensions
{
    public static void AddRange<T>(this ObservableList<T> list, IEnumerable<T> collection)
    {
        var index = list.Items.Count;
        list.Items.AddRange(collection);

        if (list.Items.Count > index)
        {
            if (list.CanNotify)
            {
                var @event = new NotifyCollectionChangedEventArgs(
                    NotifyCollectionChangedAction.Add,
                    list.Items[index..],
                    index);

                list.NotifyCollectionChanged(@event);
            }

            list.NotifyCountChanged();
        }
    }
}

More examples can be found in ObservableListExtensions.

Building

Build using dotnet.

dotnet build --configuration release

Test using dotnet.

dotnet test
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0-beta-00001 71 10/2/2024