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

No “Unassigned Local Variable” error?

c# .net c#-3.0

Why does taking the address of a variable eliminate the "Use of unassigned local variable" error?

Using windows authentication in asp.net with c#

c# asp.net sql windows-authentication

Im trying to understand how windows authentication works and how to implement it. Ive read quite a few articles and watched some quite length videos on youtube but i still cant my head around what ...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.