Launching App Market Page From App In Windows Phone 8

Introduction

This article explains the Marketplace Detail Task and how to open the Marketplace Application page from your app. This task helps to launch the App Store from our app for a specific app. It can be very useful for advertising our apps.

Marketplace Detail Task

This is a kind of launcher provided by Windows Phone to launch the Windows Phone marketplace. This task expects two parameters to be set and on the basis of those parameters users can launch the marketplace app from the app itself. 

Before using this task we need to include the following namespace:

using Microsoft.Phone.Tasks;

This task has the following properties that we can use:

  • Content Identifier
    Sets the unique identifier for the product to be displayed.
     
  • Content Type
    Sets the type of the content displayed in the store client application.
     

To use this task we need to set the preceding two properties properly.

Demo

Let's see how to use it in a contact us page of our app. Here our app page will help the user to drive to our office from their location.

XAML

<phone:PhoneApplicationPage

    x:Class="Demo.MainPage"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"

    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"

    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"

    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"

    mc:Ignorable="d"

    FontFamily="{StaticResource PhoneFontFamilyNormal}"

    FontSize="{StaticResource PhoneFontSizeNormal}"

    Foreground="{StaticResource PhoneForegroundBrush}"

    SupportedOrientations="Portrait" Orientation="Portrait"

    shell:SystemTray.IsVisible="True">

 

    <!--LayoutRoot is the root grid where all page content is placed-->

    <Grid x:Name="LayoutRoot" Background="Transparent">

        <Grid.RowDefinitions>

            <RowDefinition Height="Auto"/>

            <RowDefinition Height="*"/>

        </Grid.RowDefinitions>

 

        <!--TitlePanel contains the name of the application and page title-->

        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">

            <TextBlock Text="Demo" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>

            <TextBlock  Text="Demo" Margin="9,-7,0,0" FontSize="40" />

        </StackPanel>

 

        <!--ContentPanel - place additional content here-->

        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">

            <StackPanel Orientation="Vertical">

                <TextBlock Text="Our Apps" FontSize="45" Height="106"></TextBlock>

                <TextBlock Text="Some Apps Goes Here" FontSize="30" Height="106"></TextBlock>

                <Button Name="sendBtn" Click="sendBtn_Click"  Content="View App" HorizontalAlignment="Left" Width="186" Height="80" VerticalAlignment="Bottom" Margin="132,0,0,0"/>

            </StackPanel>

        </Grid>

    </Grid>

</phone:PhoneApplicationPage>

C# Code Behind

using Microsoft.Phone.Controls;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Net;

using System.Windows;

using System.Windows.Controls;

using System.Diagnostics;

using Microsoft.Phone.Tasks;

using System.Windows.Media;

 

namespace Demo

{

    public partial class MainPage : PhoneApplicationPage

    {

        // Constructor

        public MainPage()

        {

            InitializeComponent();

        }

 

        private void sendBtn_Click(object sender, RoutedEventArgs e)

        {

            /* Step 1 */

            Microsoft.Phone.Tasks.MarketplaceDetailTask mdt = new MarketplaceDetailTask();

            /* Step 2 */

            mdt.ContentIdentifier = "a5b88557-c574-47c6-9119-6e3040792c00";

            mdt.ContentType = MarketplaceContentType.Applications;

 

            /* Step 3 */

            mdt.Show();

 

        }

    }

}

The Show method is used to launch the task.

Output

 

 


Similar Articles