PSC.Blazor.Components.TreeView 8.0.1

dotnet add package PSC.Blazor.Components.TreeView --version 8.0.1                
NuGet\Install-Package PSC.Blazor.Components.TreeView -Version 8.0.1                
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="PSC.Blazor.Components.TreeView" Version="8.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PSC.Blazor.Components.TreeView --version 8.0.1                
#r "nuget: PSC.Blazor.Components.TreeView, 8.0.1"                
#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 PSC.Blazor.Components.TreeView as a Cake Addin
#addin nuget:?package=PSC.Blazor.Components.TreeView&version=8.0.1

// Install PSC.Blazor.Components.TreeView as a Cake Tool
#tool nuget:?package=PSC.Blazor.Components.TreeView&version=8.0.1                

TreeView component for Blazor

This component is a native Blazor TreeView component for Blazor WebAssembly and Blazor Server. The component is built with .NET7.

Installation

First, add the package to your project from NuGet.

Then, add the following line to your _Imports.razor:

@using PSC.Blazor.Components.TreeView

Usage

For adding the component to your page, use the following code:

<TreeView @key="version" Items="Items" 
          GetParent="GetParent" AllowSelection="true" 
		  @bind-SelectedItems="SelectedValues">
	<ItemTemplate>
		<div @onclick="() => { selectedItem = (selectedItem != context.Item) ? context.Item : null; }" 
		    style="background-color: @(selectedItem == context.Item ? "Highlight" : "inherit")">
 		        @context.Item
		</div>
	</ItemTemplate>
</TreeView>


@if (SelectedValues != null && SelectedValues.Any())
{
	<p>@string.Join(", ", SelectedValues)</p>
}

@code {
    private string? selectedItem;

	
	private List<string> SelectedValues = new List<string>
	{
		"3.1.1"
	};

	private List<string> Items = new List<string>
	{
		"1",
		"1.1",
		"1.2",
		"2",
		"3",
		"3.1",
		"3.1.1",
		"3.1.2"
	};

	private string GetParent(string item)
	{
		var last_period = item.LastIndexOf('.');
		if (last_period < 0)
		{
			return null; // no parent
		}
		else
		{
			return item.Substring(0, last_period);
		}
	}
}
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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
8.0.1 109 7/3/2024
8.0.0 97 7/3/2024
1.0.6 254 11/13/2023
1.0.5 155 10/25/2023
1.0.4 158 10/14/2023
1.0.3 148 10/14/2023