Select all text when tapped/focused

Hello,

I want to select all text in a SfAutocomlete any time the control gets focus/tapped. I couldn't find any property dealing with this, like SelectAllOnFocus or similar. How can I accomplish this?


Thanks for your help.

Regards

Michael



2 Replies

MI Michael May 9, 2026 02:05 PM UTC

I found a solution by hooking into Focused event. Maybe you could consider implementing a  SelectAllTextOnFocus property in the next release, which would make it simpler :-)


private void OnFocused(object? sender, FocusEventArgs e)
{
    if (sender is SfAutocomplete autocomplete)
    {
        // The SfAutocomplete control internally contains a SfInputView which inherits from Entry.
        // We need to find it to select the text.
        var entry = autocomplete.Children.OfType<Entry>().FirstOrDefault();

        if (entry != null)
        {
            Dispatcher.Dispatch(() =>
            {
                // Select all text if any
                entry.CursorPosition = 0;
                entry.SelectionLength = entry.Text?.Length ?? 0;
            });
        }
    }
}

Usage:

myAutocomplete.Focused += OnFocused;


Regards

Michael




SS Shyam Sundar Datchina Moorthy Syncfusion Team May 11, 2026 09:49 AM UTC

Hi Michael,

We have considered your requirement for Selecting All Text On Focus in SfAutoComplete as a feature request from our end. Currently, we do not have any immediate plans to implement this feature.

You can track the progress using the link below:

Include SelectAllTextOnFocus Property for Automatic Text Selection when focused in .NET MAUI | Feedback Portal

Please cast your vote to make it count. We will prioritize the features in every release based on the demands. So, this feature will be available in any of our upcoming releases. We’ll share updates once it is scheduled for release.

Please feel free to reach out if you have any further questions.

Regards,

Shyam Sundar D


Loader.
Up arrow icon