The Type Arguments Cannot be Inferred from the Usage
The ComboBox, List Box, and TagBox includes the DataAsync
property. It allows you to bind the component to a strongly typed collection that is loaded asynchronously.
The following exception occurs if you declare the DataAsync function with an incorrect signature:
The type arguments for method ‘TypeInference.CreateDxComboBox_0<T>’ cannot be inferred from the usage. Try specifying the type arguments explicitly.
To resolve the issue, ensure that the function signature meets the following requirements:
- The type of the returned value is
Task<IEnumerable<T>>
. - The function has a parameter of the CancellationToken type.
@using System.Threading;
@using System.Threading.Tasks;
<DxComboBox DataAsync="@GetDataAsync" @bind-Value="@Value" />
@code {
City Value { get; set; }
public class City {
// ...
}
public Task<IEnumerable<City>> GetDataAsync(CancellationToken ct = default) {
// ...
}
}