Articles in this section
Category / Section

How to clear the text in .NET MAUI Autocomplete (SfAutocomplete)?

2 mins read

This article demonstrates how to clear the text in the .NET MAUI Autocomplete (SfAutocomplete). To achieve this, you can set the SelectedItem property of the Autocomplete to null by handling the Button’s Clicked event.

XAML

<VerticalStackLayout Margin="10,0" Spacing="5">
    <Label Text="Choose Country Name" FontAttributes="Bold" FontSize="16"/>
    <editors:SfAutocomplete x:Name="autocomplete">
        <editors:SfAutocomplete.ItemsSource>
            <x:Array Type="{x:Type x:String}">
                <x:String>United States</x:String>
                <x:String>India</x:String>
                <x:String>France</x:String>
                <x:String>Italy</x:String>
                <x:String>Germany</x:String>
                <x:String>China</x:String>
            </x:Array>
        </editors:SfAutocomplete.ItemsSource>
    </editors:SfAutocomplete>
    <Button Text="Clear text" HorizontalOptions="Center" Clicked="OnButtonClicked"/>
</VerticalStackLayout>

C#

private void OnButtonClicked(object sender, EventArgs e)
{
    autocomplete.SelectedItem = null;
}

Output

AutoCompleteClear.gif

Conclusion

I hope you enjoyed learning how to clear the text in the .NET MAUI Autocomplete (SfAutocomplete).

You can refer to our .NET MAUI AutoComplete’s feature tour page to learn about its other groundbreaking features. You can explore our .NET MAUI Autocomplete documentation to understand how to present and manipulate data.

For current customers, you can 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 (SfAutocomplete) 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