Add Search Capability to Win8 Metro Apps Via the Search Charm

Like traditional windows apps, Windows 8 Metro style apps need to provide search functionality. Unlike traditional apps, metro style apps have the ability to support a common search functionality via the Charm, which appears on the right side of the screen. As you use it, you'll see it allows you to enter your search phrase and run it against the current app or other apps installed on your computer. Luckily, implementing search functionality (also known as search contract) within your app is not very complicated. To get started, we first need to edit the Package.appxmanifest by double clicking on it. Switch to the Declarations tab and Add Search from the Available Declarations drop down list. Once added, it then appears in the list of Supported Declarations. Now you can save the manifest, close it and start adding code to handle the search contract.

Next, we take a look at the code needed to receive the search request. Surprisingly, it's much easier than you may think to capture the search for your application. Within the App.xaml.cs class you will need to override the OnSearchActiviated method as shown below.

  protected override void OnSearchActivated(SearchActivatedEventArgs args)

The search string sent to the application can be accessed in the args parameter as the QueryText property. At this point, the query text value isn't all that useful as you do not have a place to display it. One way you can display and run your search is to create a Search Page and send the user to the page. You could then send the user to your search page using the following statement.

  (Window.Current.Content as Frame).Navigate(typeof(SearchPage), args.QueryText);

This statement will grab the Frame, Send the user to the page called SearchPage and pass the QueryText to the page. Then within the SearchPage, the search text will be accessible within the OnNavigateTo method, at which point you can run your search and display the results; however, this approach does have one big downside. For each search the user executes, the SearchPage is added to navigation tree, which means if the user tries to navigate back if provided, they will need to go back for each search executed. You could resolve this by simply having them navigate back home instead of one step at a time. You could also choose to use your main page to do double duty for search. In that case, you could use the following code, which would eliminate the stacking effect that occurs with each search.

  var rootFrame = new Frame();
  rootFrame.Navigate(typeof(MainPage), args.QueryText);
  Window.Current.Content = rootFrame;

This code snippet first creates a new Frame, navigates to the MainPage and then sets the current content to the new frame.


While the initial implementation of the Search Contract is quite easy, you will probably find the user interface implementation within your app is far more complex. In addition, you should consider the amount of time it takes for your search to execute; as such you probably should make use of asynchronous programming techniques. In any case, you should find the search contract easy to use and implement within your app.

Related Articles


  • Lisseur GHD ne coûtent pas cher, comme la petite amie de l'été 2013

    Posted by zdcweh711 on 07/16/2013 05:40am

    Lisseur avec la technologie de pointe dans la kératine, assurez-vous de protéger l'éclat naturel de vos cheveux tout en style. Il est prêt à l'emploi indicateurs, les paramètres numériques avec réglable varmed pour obtenir un revenu régulier et un système de verrouillage simple pour oppbevaring.Profesjonell pratique simplement serrer avec plaques extra-longues pour un maximum d'impact sur ​​la température long / plein hÃ¥r.Tilpass pour cheveux céramique ditt.Høyresistent revêtement avec tourmaline pour de meilleurs résultats. [url=]lisseur ghd[/url] Ces produits de beauté GHD sont adaptés pour obtenir à peu près n'importe quel type de cheveux parfaite stil.Du peut profiter de défriser les cheveux GHD attirer l'attention sur les traits de votre visage que vous préféreriez être remarqué plus. Par exemple, si vous avez des pommettes bien défini puis se redressant, votre frange ou la couche supérieure de cheveux pour mettre l'accent non seulement vos pommettes, mais même dans les yeux. Les femmes qui ont les cheveux volumineux mais ils ont peur que ces défrisants peuvent leur faire perdre leur rebond peuvent bomber dehors seule la couche supérieure pour être les cheveux très lisse sur le dessus et leurs mèches ondulées et plein d'entrain habituel ci-dessous. [url=]lisseur ghd pas cher[/url] Lorsqu'on l'interroge sur Mermaid photoshoot pour ghd, Katy Perry a déclaré: «Je l'aime parce que je suis un fan des films de Disney. Ariel est une si grande influence. C'est toujours amusant de se déguiser une fois dans la vie comme une sirène et avoir cette belle queue de poisson. David La Chapelle a fait un ensemble étonnant. C'était amusant - je dois avoir les cheveux violet qui préfigure la vraie cheveux violets j'ai eu l'automne dernier. C'est comme Lisa Frank avait fait La Petite Sirène. "Bien qu'il y ait beaucoup à avoir une couleur de cheveux que Katy Perry ne pouvait pas porter, les teintes plus foncées vraiment faire ressortir ses traits. De quelle couleur est la prochaine Katy Perry? Nous avons juste à attendre et voir!

  • Replica Oakley Caveat sale for cheap

    Posted by jtxpapthe on 07/07/2013 11:12pm

    Oakley Sunglasses Clearance ,As a brand, Oakley is well-known classic and timeless fashion fashion, this collection is exclusive and exquisite charm an issue of any truly representative. Today, Oakley on earth already has more(a) 600 patents and 800 registered trademarks, product of glasses is dizzying. There is an range to take into consideration without notice lifestyle completely, the sole gentleman, Oakley sunglasses five pillows polarization traditional glowing blue-black, and unisex. Cheap OakLey Eyepatch 2 ,Oakley, HALF X being a glasses one of the most popular, this is just dependent on time, a really coveted design development, this framework isn't as affecting the sports around the world. The latest trends, you provide on your customers so that they can give people the impression they spent a lot of money for his or her favorite, since they haven probably not like very cheap. The structural characteristics of true contact hobbies polarization and smear easily the portable titanium insole, and O Racks. Your package about shade-hole fashion shades usually care as well as the emergence of entirely very impressive about the true Oakley fashion. The newest compilation of frog skin TR90 material, alias memory plastic is soft, very feels good, not easily broken. Fake Oakley SUnglasses ,A variety of Internet Service Providers for your ease of the customer's request, select among the people apt to be accurate and appropriate glasses and identity. Oakley ski goggles separate out each one, including UVA, UVB, ultraviolet and harmful blue glow to 400nm UV baking ray advantage. cheap ray bans ,Only 1 viewpoint of an person in the shadow from the sun's standpoint, will improve your hobby, you'll be able to adjust the disposable lenses based on your tender requirements. Such a professional sports mirror with a unique personality, a full range of functionality to win the respect of various celebrities world wide. SacS Longchamp ,All Oakley sunglasses are created to perfectly fit the contours in the face, and day wearing comfort and protection. Whether it is advisable to modify?? Up your eyes to adjust to your sunglasses, which can be produced by a similar company, it may guarantee a similar service quality, mixing style and practicality. Find the ideal name can be sure of top quality and solid guarantee scheme, can not simply mention the amount of interest and welcome jealous eyes.

  • CHI Nano Keramisk Fladjern

    Posted by wanzixiao on 05/30/2013 07:52am

    [url=]Ghd fladjern tilbud[/url] Mange tror at det er nemt nok at vælge et ghd glattejern. Altså når man først har besluttet sig for at man vil have et ghd glattejern og ikke et af de andre mærker inden for glattejern. Men der findes flere forskellige modeller inden for ghd glattejern. Hvilket ghd glattejern du skal vælge afhænger af hvad krav du stiller til det og hvad type hår du har. Har du langt krøllet hår og glatter det ofte, måske endda dagligt, så kan du med fordel vælge en af de brede ghd glattejern der findes. [url=]ghd fladjern tilbud[/url] Ghd sammenlignet med tidligere produkter, denne generation af glat hår med ekstra slankt design, mode af den ydre uanstændige og nogle geniale nye unikke sted i glat hår, hårpleje og styling har gjort store forbedringer. GHD IV styler primære unikt sted: mere vækst i den keramiske varme plader. MK4 Ghd Opvarmningen er færdig vil der være et bip for at gøre dig opmærksom på at organisere ansøgning. Unik og holdbart cover design, ikke noget på egen hånd efter 15 minutter lukkede specielle kabler designet til at opretholde den fugtige keramiske feber tabletter fra skade på miljøet. [url=]glattejern ghd[/url] Så længe krøllet hår hår glatning jern vil være typisk anvendes korrekt anvendelse af de specifikke instrukser dem faktisk er beskyttet at skabe brug af. Simpelthen fordi alles vidner der er en fremragende fuld at kunne for at kunne noget ud over den grund er det virkelig er ekstremt identisk med dit hår straightner alligevel passet korrekt og derefter en mere for en mere tidsramme tidsramme. Slip af med hurtigt lige efter hver og hver og beskæftiger også ofte være bevidst ikke rigtig definitivt inddrage fremdrift af el-ledninger rundt den nøjagtige hår straightner med hinanden har at sikre, at kost regime metode er faktisk skylles opnå en fuldbyrdende en individuel krøllet hår i form af metal meget forbedret ordentlig snart efter hver og også hver design tidsramme.

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • As all sorts of data becomes available for storage, analysis and retrieval - so called 'Big Data' - there are potentially huge benefits, but equally huge challenges...
  • The agile organization needs knowledge to act on, quickly and effectively. Though many organizations are clamouring for "Big Data", not nearly as many know what to do with it...
  • Cloud-based integration solutions can be confusing. Adding to the confusion are the multiple ways IT departments can deliver such integration...

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date