FunctionZero.TreeListItemsSourceZero 1.0.0

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package FunctionZero.TreeListItemsSourceZero --version 1.0.0
NuGet\Install-Package FunctionZero.TreeListItemsSourceZero -Version 1.0.0
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="FunctionZero.TreeListItemsSourceZero" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add FunctionZero.TreeListItemsSourceZero --version 1.0.0
#r "nuget: FunctionZero.TreeListItemsSourceZero, 1.0.0"
#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.
// Install FunctionZero.TreeListItemsSourceZero as a Cake Addin
#addin nuget:?package=FunctionZero.TreeListItemsSourceZero&version=1.0.0

// Install FunctionZero.TreeListItemsSourceZero as a Cake Tool
#tool nuget:?package=FunctionZero.TreeListItemsSourceZero&version=1.0.0

FunctionZero.TreeListItemsSourceZero

The purpose of this package is to allow a ListView-type-control to behave like a TreeView and display hierarchical data. This is particularly useful if you want to adapt a GridView to behave like a TreeView, like this:

alt text

Sample Project

UWP sample project
You can also take a look at the unit tests for usage examples

Basic Usage

Your nodes must expose some way of getting their children, though the mechanism for that is entirely up to you. For example, given a tree of the following nodes:

public class MyNode
{
    public ObservableCollection<MyNode> Children{ get; }
    // Make it yours ...
}

You simply wrap your root node like this:

bool isTreeRootShown = true;        // We want the root node to be visible in our tree
var rootNode = GetRootNode();       // Get your tree data from somewhere

var rootContainer = new TreeItemSourceManager<MyNode>(isTreeRootShown, rootNode, (node) => node.Children);

The lambda function takes an instance of MyNode and must return an IEnumerable<MyNode> containing that node's children. If the IEnumerable is an ObservableCollection, the library will track changes to the underlying data.

rootContainer is now a wrapper around your rootNode and it exposes:

public ReadOnlyObservableCollection<TreeNodeContainer<T>> TreeNodeChildren { get; }

You can then bind your ListView ItemsSource to this property, write a suitable ItemTemplate, and your ListView is now a TreeView!

At a minimum, your DataTemplate will want to use the following properties on each TreeNodeContainer:

// Bind a checkbox to this to expand or collapse a node
bool IsExpanded;

// Represents the nest level of the current TreeNodeContainer
int Indent;

// This is the node that the container wraps, so represent it as you see fit
MyNode Data;

Child nodes are not enumerated until their parent container is expanded. TreeItemSourceManager provides a NodeChanged event if you want to manage virtualisation or other custom behaviour.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on FunctionZero.TreeListItemsSourceZero:

Package Downloads
FunctionZero.Maui.Controls

A MAUI Controls library featuring a cross-platform virtualizing TreeView and ListView and Expander and a really cool MaskControl and more, for all MAUI platforms.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.0-beta 1,390 12/28/2021
1.0.0 644 9/7/2019

Initial release