Implementing Search for BlogReader Windows 8 Sample

The BlogReader sample is an excellent place to start speeding up your Windows 8 development skills.  The tutorial is available here and the complete source code is available here

Create a project called WindowsBlogReader and create pages for ItemsPage.xaml, SplitPage.xaml and DetailPage.xaml and copy the corresponding code blocks from the sample listed above.

Created a class file FeedData.cs and copy the code.  Finally, create a class DateConverter.cs and copy the code associated with it.

With that you should be able to build and run the project.  There seems to be one issue in the sample feeds listed that the first week (feed1) doesn’t seem to expose it.  So you can skip that and use the second feed as first feed.  You will end up with one feed less but it works.

I had demonstrated this in the recent TechDays at Chennai.  How we can use the Search Contract and implement Search for within the Blog Titles.

First off, we need to declare that the App will be using Search Contract, in the Package.appmanifest file

image

Next, we would need a handle of the Search Contract when user types on the search window in Charms Menu.

If you had completed the code sample from the link above, you would have ItemsPage.xaml and ItemsPage.xaml.cs.  Open the ItemsPage.xaml.cs.

Import the namespaces using System.Collections.ObjectModel and System.Linq.

in the ItemsPage() constructor, right after this.InitializeComponent(); add the following code

Windows.ApplicationModel.Search.SearchPane.GetForCurrentView().QuerySubmitted += ItemsPage_QuerySubmitted;

This event is fired when users open up the Search Panel from Charms Menu, type something and hit enter.

We need to handle this event declared in the delegate.  For that we need to pull the FeedDataSource instantiation to the root of the class to make it global.

So, add the following as the first line within the partial class

FeedDataSource feedDataSource;

Also, modify the LoadState method, as follows:-

protected override void LoadState(Object navigationParameter, Dictionary<String, Object> pageState)
       {
           feedDataSource = (FeedDataSource)App.Current.Resources["feedDataSource"];

           if (feedDataSource != null)
           {
               this.DefaultViewModel["Items"] = feedDataSource.Feeds;
           }
       }

Next is to implement the ItemsPage_QuerySubmitted method

void ItemsPage_QuerySubmitted(Windows.ApplicationModel.Search.SearchPane sender, Windows.ApplicationModel.Search.SearchPaneQuerySubmittedEventArgs args)
        {
            this.DefaultViewModel["Items"] = from dynamic item in feedDataSource.Feeds
                                             where
                                             item.Title.Contains(args.QueryText)
                                             select item;
        }

As you can see we are almost using the same defaultviewmodel with the change that we are using a linq query to do a search on feeds which has the Title that matches QueryText.

With this we are ready to run the app.

Run the App.  Hit the Charms Menu with Windows + C key combination and type a text to search within the blog.

You can see that it filters the Blogs which has the matching text.

We can modify the above Linq query to do a search for the Text in other attributes like description, actual blog content etc.,

I have uploaded the complete code since the original WindowsBlogReader Code is not available for download.  You can download it from here

note:  this code is provided as-is without any warranties. 

Cheers!!!

Print | posted on Friday, December 7, 2012 1:20 PM

Comments on this post

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
This looks very interesting. I will give it a try on next days.
Left by Sarah on Dec 26, 2012 1:09 AM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
contributed to this site. definitely seriously . It is nice to know that all the information I need is right in front of me. begin to tell you how much I, for one appreciate all you do! buy pendant necklace

Left by Ganja Sober on Jan 23, 2013 10:05 PM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
This worked really good with my Windows 8. Thanks for the useful tipp.
Left by Sandy on Feb 06, 2013 11:06 PM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
I implememented that solution and it worked great. Thanks for the tipp.
Left by Annette on Feb 25, 2013 12:25 AM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
Green Power International was established in early 2002 in close cooperation with MWM GmbH (formerly Deutz Power System GmbH).
Gas engine and Bio gas
Left by shopia on Apr 06, 2013 1:13 PM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
Compaq International is committed to provide the highest quality power cable accessories. The company with it's ShrinkFit trademark stands leader in India and overseas market.
Power cable suppliers and Composite insulators
Left by shopia on Apr 06, 2013 1:14 PM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
Nice read. I think a post like this would be helpful for people who love to research and are always seeking new information to keep themselves up-to-dated on any subject. A good review indeed.

www.binaereoptionen.pw
Left by Lorena on May 28, 2013 6:51 AM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
I need by way of thanking the writer for around his very own energy. My spouse an exceptionally awesome website page the fact that similar instructions shows up, were on elementary design, having enclosed the information township particular attention to be able to your man. Some struck truly does namnogim writers that happens to be page on-line, once more because of the writer around unequalled good quality.
online slots
Left by Marcus on Jun 19, 2013 4:51 PM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
This post gives me a lot of thinking about writing good software and functions panele fotowoltaiczne.
Left by Tom on Jul 03, 2013 9:59 AM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
Create a project called WindowsBlogReader and create pages for ItemsPage.xaml, pass4sure 642-832 SplitPage.xaml and DetailPage.xaml and copy the corresponding code blocks from the sample 642-832 examcollection listed above.



Left by roter on Oct 01, 2013 3:52 PM

# re: Implementing Search for BlogReader Windows 8 Sample

Left by fsd on Oct 07, 2013 2:41 AM

# Mr

Requesting Gravatar...
This is good article, very informative and on the spot. I'm happy I stopped by and I'm very fond of the fact that I have learned something today. Keep up the good work. lead to the overdraft
Left by Night Mare on Oct 12, 2013 9:26 PM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
there is also a problem with choosing the way you want to order the products.Rolex Replica Orologi
Left by Aisin on Oct 23, 2013 1:25 PM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
This is the very good idea! Just want to say thank you for information, Just continue to the write such a position. I will be your faithful reader. Thank you again. yellow throw pillows


Left by sara10 on Dec 23, 2013 4:04 AM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
A very wonderful article. It touches a lot of urgent issues of our society. We can not be indifferent to these problems. This article gives good ideas and concepts. Keep it up personalized gifts for her
Left by mada on Dec 29, 2013 8:44 PM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
Thanks for your great sharing and I hope you will more famous day by day. My all the best for your legendary writing.custom iphone 5 cases
Left by madalina on Jan 02, 2014 5:46 PM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
Thank you for presenting your points and providing this information. I have learned something about this topic House cleaning Chicago
Left by VERA on Jan 05, 2014 8:21 PM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
Thank you for presenting your points and providing this information. I have learned something about this topic House cleaning Chicago
Left by VERA on Jan 05, 2014 8:21 PM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
It is nice that you posted something like this and I am quite lucky to read it. Thanks for posting this! Rolex Daytona Replica
Left by andyu on Jan 15, 2014 10:29 AM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
I had demonstrated this in the recent TechDays at Chennai torrent downloads . How we can use the Search Contract and implement Search for within the Blog Titles.
Left by derek on Jan 29, 2014 3:36 PM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
We have to handle this occasion announced in the representative. For that we have to draw the Feeddatasource instantiation to the base of the class to make it worldwide.management paper
Left by management paper on Mar 13, 2014 12:52 PM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
To whom do I send a question


Cieszę się że fotowoltaika i jej znaczenie wzrasta wraz z kryzysem energetycznym panele fotowoltaiczne są coraz popularniejsze.
Left by Tom on Mar 20, 2014 2:21 PM

# hermes sac

Requesting Gravatar...
I tag it to my favorites internet site list and will be checking back soon. Please check out my web site also hermes sac and let me know what you think.
Left by effreying on Apr 16, 2014 2:40 PM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
A paramount window coating thought for your home will be as simple as putting in some engaging window shades. One of numerous key issues to recall when introducing blinds is to guarantee that your extents are overall adjusted for the room. In the event that the configuration has one segment that is not relatively the best possible size it may divert from your complete effect of your window ornamentation.writing a statement of interest
Left by writing a statement of interest on May 03, 2014 2:35 PM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
That is very helpful. It provided me a few ideas and I'll be posting them on my web site eventually. I'm bookmarking your site and I'll be back again. Thank you again!montbrillantreplica
Left by ak47 on May 12, 2014 1:54 PM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
Your post was good and the information that you giving your post that was really cool. I like it very much. Thanks for posting this. Please
share more information and I will bookmark to my blog sewa mobil jakarta
Left by StephJosh on Jun 05, 2014 9:59 AM

# Mr

Requesting Gravatar...
A web journal web index principle concentrates on discovering website entrances that match particular essential words and site passages that connection to whatever site locations are entered by the individual doing a pursuit. Internet searchers use insects and bots to get Web pages and programming projects to get postings filed. Nonetheless, blog registries are predominately run and kept up by people. convert pdf files to excel
Left by micheal justins on Jun 13, 2014 11:18 AM

# Revision Jönköping

Requesting Gravatar...
A web journal web index principle concentrates on discovering website entrances that match particular Revision Jönköping essential words and site passages that connection to whatever site locations are entered by the individual doing a pursuit. Internet searchers use insects and bots to get Web pages
Left by owais93 on Jun 16, 2014 2:01 PM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
Build a project referred to as WindowsBlogReader and generate webpages with regard to ItemsPage. xaml, SplitPage. xaml and DetailPage. xaml and copy the particular equivalent program code obstructs from the small sample in the above list. The contestants within the show works on Globe Gym equipment although with the Largest Loser Ranch in Calabasas, Florida, then from planet fitness centers next to their particular houses, dealing with Globe Physical fitness fitness professionals.
Left by planet fitness on Jun 17, 2014 6:52 PM

# re: Implementing Search for BlogReader Windows 8 Sample

Requesting Gravatar...
Numerous PLAYSTATION PORTABLE sites will not supply high quality information and maybe they are on occasion abundant download free full movies with spyware and adware. As a substitute, learn how to receive films towards the PLAYSTATION PORTABLE inside of quick and easy steps.
Left by owais93 on Jun 23, 2014 2:10 PM

Your comment:

 (will show your gravatar)