Controllo ListBox

Il controllo ListBox permette di selezionare uno o più valori a partire da una sorgente dati.
Se DataType è impostato come Boolean, converte automaticamente il valore selezionato come true.
 
 
Personalizzazione
Possiamo impostare una sorgente dati personalizzata specificando il valore ControlClass per DataSourceMode e inserendo namespace e nome classe nella proprietà del controllo CustomControlClass.
 
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq;
using Microsoft.Extensions.DependencyInjection;
using DataWeb.Structure;
using DataWeb.Identity;
using DataWeb.Data;
using DataWeb.Data.Controls;
using DataWeb.Web.App.Infrastructure;
using System.Threading;

namespace DataWeb.Web.App.DataWeb.Data.Controls
{
    public class Product_RelatedProducts(Form form, IServiceProvider serviceProvider) :  ListBox(form, serviceProvider)
    {
        private readonly ProductStore productRepository = serviceProvider.GetService<ProductStore>();

        public override async Task<IEnumerable<List.ListItem>> GetListValuesAsync(Dictionary<string, object> parameters, IUser user, string itemId = null, NavigationContext navigationContext = null, CancellationToken cancellationToken = default)
        {
            var products = await productRepository.GetProductsAsync(new ProductStore.Filter(), "en-US");

            return products.Select(x => new List.ListItem { Title = x.Code, Value = x.Code });
        }
    }
}