Searching Marketplace in Windows Phone with MarketplaceSearchTask using C#

The Windows Phone 7 SDK provides the MarketplaceSearchTask launcher that lets the developers to search Microsoft Marketplace for Windows Phone 7 in the App .

The MarketplaceSearchTask launches the Windows Phone Marketplace client application and then displays the search results .

You must also provide the keyword or search terms via the property SearchTerms .

Searching Marketplace in Windows Phone with MarketplaceSearchTask using C#

The MarketplaceSearchTask is defined in the namespace Microsoft.Phone.Tasks ,so you might need to include this namespace incase if it is not included in the c# code behind .

Just create an instance of MarketplaceSearchTask and set the SearchTerms and then Call the Show Method of the MarketplaceSearchTask .

public MainPage()
{
     InitializeComponent();
     MarketplaceSearchTask marketplaceSearchTask = new MarketplaceSearchTask();
     marketplaceSearchTask.SearchTerms = "Number Converter";
     marketplaceSearchTask.Show();

}

This will display the MarketPlace Search Screen  .

Searching Marketplace in Windows Phone with MarketplaceSearchTask using C#

You can also set the ApplicationType so that Search is done for Application or Music with the property ContentType of MarketplaceSearchTask like below .

public MainPage()
{
     InitializeComponent();
     MarketplaceSearchTask marketplaceSearchTask = new MarketplaceSearchTask();
     marketplaceSearchTask.SearchTerms = "Number Converter";
     marketplaceSearchTask.ContentType = MarketplaceContentType.Applications;
     marketplaceSearchTask.Show();

}

The ContentType here is the MarketplaceContentType enum that id again defined in the namespace Microsoft.Phone.Tasks