Articles in this section
Category / Section

How to Receive the Text Changed Event in the .NET MAUI Autocomplete?

2 mins read

This article demonstrates how to receive the Text Changed event in the .NET MAUI Autocomplete. While there is currently no direct event support for TextChanged, you can utilize the TextChanged event from the Entry element, which is a child of the .NET MAUI Autocomplete, to set up an event handler that responds to text changes. Here’s how you can achieve this:

C#

public partial class MainPage : ContentPage
{
    public MainPage()
    {
        InitializeComponent();
        
        // Get the Entry control from SfAutocomplete
        var entry = GetEntryFromAutoComplete(autoComplete);
        if (entry != null)
        {
            // Attach the TextChanged event handler
            entry.TextChanged += MainPage_TextChanged;
        }
    }

    private void MainPage_TextChanged(object? sender, TextChangedEventArgs e)
    {
        // Handle the text change event here
    }
    
    private Entry? GetEntryFromAutocomplete(SfAutocomplete sfAutocomplete)
    {
        foreach (var child in sfAutocomplete.Children)
        {
            if (child is Entry entry)
            {
                return entry;
            }
        }
        return null;
    }
}

Download the complete sample from GitHub.

Conclusion

I hope you enjoyed learning how to receive the text changed event in the .NET MAUI Autocomplete.
You can refer to our .NET MAUI Autocomplete feature tour page to learn about its other groundbreaking features. Explore our .NET MAUI Autocomplete documentation to understand how to present and manipulate data.

For current customers, check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to explore our .NET MAUI Autocomplete and other .NET MAUI components.

Please let us know in the comments section below if you have any queries or require clarification. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied