Floating FB popout byF5debug

101 How to on Windows Phone – How to #13 – Play with MarketPlace Hub Task in Windows Phone

 

In this short tutorial we are going to see how to use the Market Place Hub task, this task is used to launch the MarketPlace application on the device where we can specify the type of application (basically a category) from the market place. The content type can be of a music or application based on the search content type from the user perspective based on the requirement. So basically we can use this task to search a wide category of application from the Windows Phone Market place.  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 Market Place Hu Task as shown in the screen below.

clip_image002

Now drag and drop few controls to the screen which is used to trigger event that launches the Market Place Hub Task with the required content type specified by the end user. Once we designed the screen with the controls we can see the screen looks like below.

clip_image004

Now we need to write our code in the button click event to trigger the Market Place Hub 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.

using Microsoft.Phone.Tasks;

Next is to add the below code to the button click event which basically creates an instance of the Market place task and provide a content type which categorizes and pulls the data from the market place as shown in the code below. Marketplace Content Type can be of Application or music which are the 2 hubs which can be pulled with the help of this MarketPlace Hub task.

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Tasks;

namespace F5debugHowto13
{
    public partial class MainPage : PhoneApplicationPage
    {
        // Constructor
        public MainPage()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            MarketplaceHubTask marTask = new MarketplaceHubTask();
            marTask.ContentType = MarketplaceContentType.Applications;
            marTask.Show();
        }
    }
}

clip_image006

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.

Output Screens:

clip_image008

So in this short tutorial we have seen how to use the Market place hub task to pull out the application details from the windows phone market place based on the category that is required for the end user. That’s it from this short tutorial on Windows Phone see you all in the next tutorial soon. Mean while Happy Programming!!!

About Author: Karthikeyan Anbarasan, Microsoft MVP (Most Valuable Professional) in ASP.NET/IIS Architecture. He is the Founder and Chief Editor of the www.f5debug.net website and has authored books on Windows Phone and Business Intelligence(SSIS). He is also a Passionate Speaker and a Blogger on Microsoft Technologies.

You can Join Me On: Facebook, Twitter, Google Plus, LinkedIn

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Recent Posts

Random Posts

Most Viewed

URL Shortner

Create your own short urls!!!

Site Counter

free counters

Disclaimer

This is a personal weblog. The opinions expressed here represent my own and not those of my employer. For accuracy and official reference refer to MSDN/ TechNet. I have documented my personal experience on this blog.

Protected by Copyscape Web Plagiarism Finder

Site Meter