Custom Search on objects in Metro / Modern UI

I'm implementing an application for Windows 8. It will search a quite large number of data from xml.

So for now I'm using a text box and list view to show the search results, but when i use the textbox event TextChanged is slows down the typeing, because it executes a new search for each letter typed.

So the question is, how to in metro / modern ui make a delay, to trigger the event after few letters are typed, not one.

Answers


You should not create your own Search experience. You should hook into the SearchPane and handle it there.

SearchPane searchPane = SearchPane.GetForCurrentView();
searchPane.QuerySubmitted += searchPane_QuerySubmitted;
searchPane.SuggestionsRequested += searchPane_SuggestionsRequested;

You can then handle the events as necessary in the handlers. If you are providing suggestions and you have a slow running process that will by async, you msut get a deferral.

void searchPane_SuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
{
    var deferral = args.Request.GetDeferral();
    // do real time type ahead here
    deferral.Complete();
}

void searchPane_QuerySubmitted(SearchPane sender, SearchPaneQuerySubmittedEventArgs args)
{
    // complete search here
}

You are discouraged from running anything that might bog down the UI as a synchronous task. Try running it as a background task which updates the UI on completion. See Background Task and TimeTrigger for more information. On task completion use the Core Dispatcher to update the UI. Core Dispatcher example


Why not use the "Leave" event instead of the text changed event of a text box? Would make it a lot smoother and would be when the user has finished their input inside the text box.


Need Your Help

Redirect users with suspended accounts without creating redirect loop

c# asp.net-mvc membership subscription

I have a subscription based MVC 2 application with the basic .NET Membership service in place (underneath some custom components to manage the account/subscription, etc). Users whose accounts have