In this short tutorial we are going to see how to use the Market Place Search task in Windows Phone Development. With MarketPlace Search task we can provide an option to the end user to search the Windows Phone market place for some specified application or some specified music based on the search filter. Marketplace Search task is one of the launcher available with Windows Phone which basically searches the Market place client application and display the search result based on the filters. Let us see the steps on how to achieve this task in real time for a Windows phone application. [more]
Open Visual Studio 2010 IDE and create a new Silverlight for Windows Phone project with a valid project name as shown in the screen below. Once the project is created add some controls which are used to trigger the MarketPlace Search Task as shown in the screen below.
Now drag and drop few controls to the screen which is used to trigger event that launches the Market Place Search Task with the required content type and the search filter (basically the keyword on which it searches the market place) specified by the end user. Once we designed the screen with the controls we can see the screen looks like below.
Now we need to write our code in the button click event to trigger the Market Place Search task on the user click. To do that just go to the code behind and first add the USING handler code on top with the existing using statements as shown in the code below.
Next is to add the below code to the button click event which basically creates an instance of the Market place search task and provide a content type (basically as Application or Music) and a search filter (User entered search filter) which categorizes and pulls the data from the market place as shown in the code below.
public partial class MainPage : PhoneApplicationPage
private void button1_Click(object sender, RoutedEventArgs e)
MarketplaceSearchTask mpTask = new MarketplaceSearchTask();
mpTask.ContentType = MarketplaceContentType.Applications;
mpTask.SearchTerms = textBox1.Text.ToString();
Now we are done with our code, just run the application by pressing F5 directly from the keyboard or we can use the Build and execute the project option from the tool bar to run the application. Once the Build is successful we can see the Windows Phone emulator with the application and the expected outputs as shown in the screens below.
So here we have filtered the application based on the keyword F5debug, which basically searches not only the application names but also it searches the application publisher name as well which is shown in the screen shots above. The above listing has the application name starting with F5debug as well it pulls the application published by the publisher name F5debug. That’s it from this short tutorial on Windows Phone see you all in the next tutorial soon. Mean while Happy Programming!!!