DropDownList control

The DropDownList control allows selecting a value from a data source.
 
Customization
We can set a custom data source by specifying the value ControlClass for DataSourceMode and inserting the namespace and class name in the property of the control 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.WebApp.Infrastructure;
using Microsoft.Extensions.Localization;

namespace MyApp.DataWeb.Data.Controls
{
    public class Category_AreaName :  DropDownList
    {
        private readonly AreaRepository areaRepository;
        private readonly IStringLocalizer localizer;

        public Category_AreaName(Form form, IServiceProvider serviceProvider) : base(form, serviceProvider)
        {
            areaRepository = serviceProvider.GetService<AreaRepository>();
            localizer = serviceProvider.GetService<IStringLocalizer>();
        }

        public override async Task<IEnumerable<List.ListItem>> GetListValuesAsync(Dictionary<string, object> parameters, IUser user, string itemId = null, NavigationContext navigationContext = null)
        {
            var areas = await areaRepository.GetAreasAsync(new AreaRepository.Filter(), "en-US");

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