More on Search in WInRT: Search history
A few weeks back I asked on Twitter if you preferred to have search history on or off when doing searches in an application. The majority said off, some said a limited history and some preferred to have a button allowing them to toggle history on or off.
More on Search in Windows Store Apps:
How do we work with search history in Windows Store Apps?
SearchHistory is enabled by default but can be disabled with the SearchHistoryEnabled property, and you can even grab a SearchHistoryContext if you want different contexes depending on where the user does the search.
To access the global object that manages search, be that panel or SearchBox control, you can use the SearchSuggestionManager, found under: Windows.ApplicationModel.Search.Core.SearchSuggestionManager
Two methods might be of interest, ClearHistory and AddToHistory. The two do exatcly what you would think. It might be just me being tired, but I couldn’t figure out a better way to limit the search history items shown besides creating a limited queue adding search items to them as the user did the search, and clearing the list before appending the queue items.
It’s 5:20 AM so it might not be the best or brightest idea I’ve had, let me know if there are other ways. Anyway, there is a manager object, and methods to clear or add to the search history. Use them wisely.
Oh, and let’s not forget SetLocalContentSuggestionSettings, which:
Specifies whether suggestions based on local files are added automatically to the Suggestions collection, and defines the criteria that Windows uses to locate and filter these suggestions.
Basically you can provide suggestions based on local files, and you can pass in an Advanced Query Filter to grab exactly what you want, the folder used, properties to match etc. Quite neat.
// searchbox or pane => they use the same manager
var searchManager = new Windows.ApplicationModel.Search.Core.SearchSuggestionManager();
// clear history
// add to history
// Adding from limited queue
foreach (var historyItem in _searchHistory)