New to Telerik UI for .NET MAUI? Start a free 30-day trial

Remote Search in .NET MAUI AutoComplete

The Remote Search functionality of the AutoComplete control allows you to take the user input, trigger custom searching algorithm and assign the results to the ItemSource of the control.

  • LoadingTemplate(DataTemplate)—Defines the template of the loading view.

Implement your custom searching algorithm inside the body of the TextChanged event handler.


Here is an example how the RadAutoComplete Remote Search works:

1. Create the needed business objects, for example type Client with the following properties:

public class Client
    public Client() { }

    public Client(string name, string imageSource)
        this.Name = name;
        this.ImageSource = imageSource;

    public Client(string name, string email, string imageSource)
        this.Name = name;
        this.Email = email;
        this.ImageSource = imageSource;

    public string Name { get; set; }
    public string Email { get; set; }
    public string ImageSource { get; set; }

2. Create a ViewModel with a collection of Client objects:

public class ClientsViewModel
    public ClientsViewModel()
        this.Source = new ObservableCollection<Client>()
            new Client("Freda Curtis", "", "available.png"),
            new Client("Jeffery Francis", "", "away.png"),
            new Client("Eva Lawson", "", "available.png"),
            new Client("Emmett Santos", "", "busy.png"),
            new Client("Theresa Bryan", "", "available.png"),
            new Client("Jenny Fuller", "", "busy.png"),
            new Client("Terrell Norris", "", "away.png"),
            new Client("Eric Wheeler", "", "away.png"),
            new Client("Nida Carty", "", "away.png"),
            new Client("Niki Samaniego", "", "busy.png")

    public ObservableCollection<Client> Source { get; set; }

3. Use the following snippet to declare a RadAutoComplete in XAML:

<telerik:RadAutoComplete x:Name="autoCompleteView"
                         Placeholder="Remote Search..."
            <HorizontalStackLayout HorizontalOptions="Center"
                                   Margin="0, 20, 0, 20">
                <Label Text="Searching... " 
                <telerik:RadBusyIndicator x:Name="busyIndicator" 
            <Label Text="No match was found for the specific search. Please try again."

4. Create a custom searching algorithm and assign the result to the control's ItemsSource inside the TextChanged event handler:

private void OnTextChanged(object sender, Microsoft.Maui.Controls.TextChangedEventArgs e)
    var autoComplete = (RadAutoComplete)sender;
    autoComplete.ItemsSource = null;

    this.currentText = e.NewTextValue ?? "";

    if (this.currentText.Length >= autoComplete.SearchThreshold && !this.isRemoteSearchRunning)
        this.isRemoteSearchRunning = true;
        Dispatcher.StartTimer(TimeSpan.FromMilliseconds(1500), () =>
            this.isRemoteSearchRunning = false;
            string searchText = this.currentText.ToLower();
            autoComplete.ItemsSource = this.viewModel.Source.Where(i => i.Name.ToLower().Contains(searchText));
            return false;

This is the result when LoadingTemplate is searching for results:

.NET MAUI AutoComplete Remote Search Searching

This is the search complete results:

.NET MAUI AutoComplete Remote Search Results

For the AutoComplete Remote Search example refer to the SDKBrowser Demo application.

See Also

In this article