Back to Devexpress

The Type Arguments Cannot be Inferred from the Usage

blazor-403271-troubleshooting-common-component-issues-the-type-arguments-can-not-be-inferred-from-the-usage.md

latest1.3 KB
Original Source

The Type Arguments Cannot be Inferred from the Usage

  • Oct 16, 2024

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.

  • Razor

razor
@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) {
        // ...
    }
}