Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

How to add marketplace review using the Cimbalino Windows Phone Toolkit

From Wiki
Jump to: navigation, search

This code example shows how to add marketplace review to your app using MarketplaceReviewService from the Cimbalino Windows Phone Toolkit.

SignpostIcon XAML 40.png
WP Metro Icon WP8.png
SignpostIcon WP7 70px.png
Article Metadata
Code Example
Installation file: MarketplaceReviewService (github)
Tested with
SDK: Windows Phone 8.0 SDK, Windows Phone 7.1.1 SDK
Devices(s): Nokia Lumia 800, 920
Created: saramgsilva (05 Nov 2013)
Last edited: influencer (01 Feb 2014)



The Cimbalino Windows Phone Toolkit delivers a set of useful and powerful MVVM-compatible tools and services to help developers build Silverlight applications for Windows Phone. The Toolkit is divided in projects which deliver different features, ranging from base MVVM services and helpers, through to code for background agents, and for accessing media library, location services etc. The base project (Cimbalino.Phone.Toolkit) contains base MVVM services, some very useful converters, helper classes and extension methods.

The Cimbalino Toolkit's "Market Place Review" service is used to launch the marketplace review screen for an app, making it easier for users to rate and review. The kit provides both the IMarketplaceReviewService interface and its implementation MarketplaceReviewService required to register the service in MVVM Light (note that MVVM and the MVVM Light Toolkit are not "preconditions" to use this service).

This article explains how to use the service in an MVVM Light app. Developers should first read How to use MVVM Light Toolkit for Windows Phone for a general overview of MVVM Light and how to use services.

A screenshot of the example app, with the icon used to launch marketplace review, is shown below.


Building the example code

The source code for the code example is available here: MarketplaceReviewService (github).

To build the source code you will also need the MVVM Light Toolkit and the Cimbalino Windows Phone Toolkit. Their packages are available in the Nuget Package Manager. For more details see:

The sample is built using MVVM Light and the article does not go into great detail about the plumbing/infrastructure provided by the toolkit. For more information see:

Registering the service

Register the service in the ViewModelLocator constructor as shown below (ViewModelLocator.cs).

  1.         public ViewModelLocator()
  2.         {
  3.             ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
  5.             if (!SimpleIoc.Default.IsRegistered<IMarketplaceReviewService>())
  6.             {
  7.                 SimpleIoc.Default.Register<IMarketplaceReviewService, MarketplaceReviewService>();
  8.             }
  10.             SimpleIoc.Default.Register<MainViewModel>();
  11.         }

In the next section we see that the MainViewModel constructor takes a IMarketplaceReviewService parameter. When ViewModelLocator creates the view model it recognises that the parameter is registered, creates an instance of the MarketplaceReviewService and passes it to MainViewModel.

Implementing the ViewModel

Implement the MainViewModel as shown below. The highlighted sections show the MainViewModel constructor taking the IMarketplaceReviewService parameter and assigning it to the private variable, and later on the variable being used to show the market place review prompt.

  1.     /// This class contains properties that the main View can data bind to.
  2.     public class MainViewModel : ViewModelBase
  3.     {
  4.         /// The marketplace review service.
  5.         private readonly IMarketplaceReviewService _marketplaceReviewService;
  7.         /// The public application url.
  8.         private readonly string _appUrl;
  10.         /// The marketplace review service
  11.         public MainViewModel(IMarketplaceReviewService marketplaceReviewService)
  12.         {
  13.             _marketplaceReviewService = marketplaceReviewService;
  15.             RateCommand = new RelayCommand(Rate);
  16.         }
  18.         /// Gets the rate command.
  19.         public ICommand RateCommand { get; private set; }
  21.         /// The rate.
  22.         private void Rate()
  23.         {
  24.             _marketplaceReviewService.Show();
  25.         }
  26.     }

Implementing the view

The rest of the app is "plumbing" to hook up the MainViewModel to the View and send commands back to the invoke the service. How to use MVVM Light Toolkit for Windows Phone explains most of what is going on, but for completeness the MainPage.xaml is as shown below:

  1. <phone:PhoneApplicationPage x:Class="CimbalinoSample.MainPage"
  2.                             xmlns=""
  3.                             xmlns:x=""
  4.                             xmlns:cimbalino="clr-namespace:Cimbalino.Phone.Toolkit.Behaviors;assembly=Cimbalino.Phone.Toolkit"
  5.                             xmlns:d=""
  6.                             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
  7.                             xmlns:mc=""
  8.                             xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
  9.                             xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
  10.                             DataContext="{Binding MainViewModel,
  11.                                                   Source={StaticResource Locator}}"
  12.                             FontFamily="{StaticResource PhoneFontFamilyNormal}"
  13.                             FontSize="{StaticResource PhoneFontSizeNormal}"
  14.                             Foreground="{StaticResource PhoneForegroundBrush}"
  15.                             Orientation="Portrait"
  16.                             SupportedOrientations="Portrait"
  17.                             shell:SystemTray.IsVisible="True"
  18.                             mc:Ignorable="d">
  20.     <!--  LayoutRoot is the root grid where all page content is placed  -->
  21.     <Grid x:Name="LayoutRoot" Background="Transparent">
  22.         <Grid.RowDefinitions>
  23.             <RowDefinition Height="Auto" />
  24.             <RowDefinition Height="*" />
  25.         </Grid.RowDefinitions>
  27.         <!--  TitlePanel contains the name of the application and page title  -->
  28.         <StackPanel x:Name="TitlePanel"
  29.                     Grid.Row="1"
  30.                     Margin="0,5,12,396">
  31.             <TextBlock Margin="12,0"
  32.                        Style="{StaticResource PhoneTextTitle2Style}"
  33.                        Text="Cimbalino Toolkit Sample" />
  34.         </StackPanel>
  35.         <TextBlock Grid.RowSpan="2"
  36.                    Margin="12,50,-3,487"
  37.                    Style="{StaticResource PhoneTextTitle3Style}"
  38.                    TextWrapping="Wrap">
  39.             This samples has the goal to show how to use Cimbalino Toolkit -  MarketplaceReviewService
  40.         </TextBlock>
  41.         <!--  ContentPanel - place additional content here  -->
  42.         <Grid x:Name="ContentPanel"
  43.               Grid.Row="1"
  44.               Margin="12,0,12,0" />
  45.         <i:Interaction.Behaviors>
  46.             <cimbalino:ApplicationBarBehavior>
  47.                 <cimbalino:ApplicationBarIconButton Command="{Binding RateCommand,
  48.                                                                       Mode=OneTime}"
  49.                                                     IconUri="/Images/appbar.rate.png"
  50.                                                     Text="Rate it" />
  51.             </cimbalino:ApplicationBarBehavior>
  52.         </i:Interaction.Behaviors>
  53.     </Grid>
  55. </phone:PhoneApplicationPage>

The first highlighted lines show binding the MainViewModel as a DataContext for the page.

DataContext="{Binding MainViewModel, Source={StaticResource Locator}}"

The second highlighted section sets the application bar "Rate it" icon and binds to RateCommand in the MainViewModel.

<cimbalino:ApplicationBarIconButton Command="{Binding RateCommand,

Text="Rate it" />

Related samples

Source Code

Source code is available here

This page was last modified on 1 February 2014, at 17:05.
98 page views in the last 30 days.