I would like to use an event that fires only when the user clicks on an item from the dropdown.
=====
ADMIT EDIT:
Here is a possible way to achieve this now:
<TelerikComboBox @bind-Value=@SelectedValue
Data="@ComboBoxData"
ValueField="ProductId"
TextField="ProductName">
<ItemTemplate>
@{
var currentItem = context as Product;
<div onclick="@(() => OnClickHandler(currentItem))" style="width:100%">
@currentItem.ProductName
</div>
}
</ItemTemplate>
</TelerikComboBox>
@code {
private void OnClickHandler(Product item)
{
//the application logic here
}
public IEnumerable<Product> ComboBoxData { get; set; }
public int SelectedValue { get; set; } = 2;
protected override void OnInitialized()
{
List<Product> products = new List<Product>();
for (int i = 1; i < 10; i++)
{
products.Add(new Product()
{
ProductId = i,
ProductName = $"Product {i}",
UnitPrice = (decimal)(i * 3.14)
});
}
ComboBoxData = products;
base.OnInitialized();
}
public class Product
{
public int ProductId { get; set; }
public string ProductName { get; set; }
public decimal UnitPrice { get; set; }
}
}