BlazorMultiselectComponent 1.0.5

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

// Install BlazorMultiselectComponent as a Cake Tool
#tool nuget:?package=BlazorMultiselectComponent&version=1.0.5

Blazor Multiselect Component

I built this component because I found the collection binding to InputSelect tedious. This component allows you to bind complex types to a simple multiselect.

PARAMETERS

TOption Type

The type for the collection being passed to the component.

Label string

The text that labels the multiselect input box on the page.

Options ICollection<TOption>?

A collection of all of the possible options for the component to display.

DisplayField string

The string name of the property to use when displaying the options.
Preferred way of passing this parameter is by nameof(Model.Property).

SelectedChanged EventCallback<ICollection<TOption>>

The callback which is invoked whenever the underlying value is updated.

Selected ICollection<TOption>

The value that the component holds.

HOW TO USE

Inside of an EditForm, bind your collection to the BlazorMultiSelectComponent.

Say we have a product with a list of categories:

    class ProductCategory {
        public int Id { get; set; } 
        public string Name { get; set; }
    }
    class Product {
        ...
        public virtual ICollection<ProductCategory> Categories { get; set; } = new List<ProductCategory>();
        ...
    }

    protected List<ProductCategory> AllCategories { get; set; } = new List<ProductCategory>()
    {
        new ProductCategory
        {
            Id = 1,
            Name = "Category 1"
        },
        new ProductCategory
        {
            Id = 2,
            Name = "Category 2"
        },
        new ProductCategory
        {
            Id = 3,
            Name = "Category 3"
        }
    };

    protected Product Product { get; set; } = new Product();

Bind it to the component like so:

<EditForm>
    ...
    <BlazorMultiSelectComponent.MultiSelect @bind-Selected=@(Product.Categories) Label="Categories" DisplayField=@(nameof(ProductCategory.Name)) Options="AllCategories" />
    ...
</EditForm>
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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. 
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
1.0.5 198 8/9/2023
1.0.4 117 8/8/2023
1.0.3 124 8/8/2023
1.0.2 115 8/8/2023
1.0.1 152 4/14/2023
1.0.0 156 4/13/2023