Windows phone - Supprimer l'historique d'une searchBox / SearchBar dynamiquement

 01/01/2019 |   Admin |  Xamarin


Pour supprimer l'historique d'une recherche dans un composant de type SearchBox sur Windows Phone ou du composant SearchBar sur Xamarin avec Windows, il suffit d'éxécuter ce code:

 
// Clear SearchBar history
var searchManager = new Windows.ApplicationModel.Search.Core.SearchSuggestionManager();
searchManager.ClearHistory();

Avec Xamarin, il suffit d'éxécuter ce code dans le App.xaml.cs de l'application Windows après cette ligne de code:

 
 // Place the frame in the current Window
Window.Current.Content = rootFrame;