×
Namespaces

Variants
Actions
(Difference between revisions)

Como avaliar uma aplicação usando Cimbalino Windows Phone Toolkit

From Nokia Developer Wiki
Jump to: navigation, search
hamishwillee (Talk | contribs)
m (Hamishwillee - Add example code source link in github)
hamishwillee (Talk | contribs)
m (Hamishwillee - Fix categories)
Line 1: Line 1:
[[Category:Lang-Portuguese]][[Category:MVVM Light Toolkit]][[Category:Cimbalino Windows Phone Toolkit]][[Category:App Marketing for Windows Phone]][[Category:How To]][[Category:Windows Phone 7.5]][[Category:Windows Phone 8]][[Category:XAML]]
+
[[Category:Lang-Portuguese]][[Category:App Marketing for Windows Phone]][[Category:Cimbalino Windows Phone Toolkit]][[Category:MVVM Light Toolkit]][[Category:How To]][[Category:Code Examples]][[Category:XAML]][[Category:Windows Phone 7.5]][[Category:Windows Phone 8]]
 
{{Abstract| Este artigo tem como objetivo mostrar como usar Cimbalino Windows Phone Toolkit - MarketplaceReviewService.}}
 
{{Abstract| Este artigo tem como objetivo mostrar como usar Cimbalino Windows Phone Toolkit - MarketplaceReviewService.}}
 
{{SeeAlso| [[How to integrate store review into an app on Windows Phone ]]}}
 
{{SeeAlso| [[How to integrate store review into an app on Windows Phone ]]}}
Line 206: Line 206:
  
 
O código fonte pode ser obtido [https://github.com/saramgsilva/CimbalinoToolkitSamples/tree/master/How%20to%20use%20Cimbalino%20Windows%20Phone%20Toolkit%20-%20MarketplaceReviewService aqui].
 
O código fonte pode ser obtido [https://github.com/saramgsilva/CimbalinoToolkitSamples/tree/master/How%20to%20use%20Cimbalino%20Windows%20Phone%20Toolkit%20-%20MarketplaceReviewService aqui].
 +
 +
<!-- Translation --> [[en:How to add marketplace review using the Cimalino Windows Phone Toolkit]]

Revision as of 08:39, 15 November 2013

Este artigo tem como objetivo mostrar como usar Cimbalino Windows Phone Toolkit - MarketplaceReviewService.

SignpostIcon XAML 40.png
WP Metro Icon WP8.png
SignpostIcon WP7 70px.png
Article Metadata

Exemplo de código
Código fonte: MarketplaceReviewService (github)

Testado com
SDK: Windows Phone 8.0 SDK, Windows Phone 7.1.1 SDK
Aparelho(s): Nokia Lumia 800, 920

Compatibilidade
Artigo
Tradução:
Por saramgsilva
Última alteração feita por hamishwillee em 15 Nov 2013

Contents

Introdução

Cimbalino Windows Phone Toolkit é um conjunto de itens uteis e poderosos para ajudar na implementação de aplicações Windows Phone. Projeto base do toolkit contendo serviços para implementação do padrão de MVVM, conversores, classes auxiliares, métodos de extensões;

  • IMarketplaceReviewService é a interface (Cimbalino toolkit - código fonte aqui) que representa o serviço com a capacidade de mostrar o ecrã dos comentários do mercados na aplicação. A Implementação é MarketplaceReviewService.

Contruindo o exemplo

Os pacotes estão disponíveis em Nuget Package Manager (para ambos os "targets") e podem ser instalados, para mais detalhes consultar: Como instalar os pacotes Cimbalino Windows Phone Toolkit. O exemplo deste artigo usa MVVM Light para ajudar na implementação do padrão MVVM, para mais detalhes consultar:

Vamos começar!

Devemos começar por registar cada serviço no ViewModelLocator, como podemos ver de seguida:

/// <summary>
/// This class contains static references to all the view models in the
/// application and provides an entry point for the bindings.
/// </summary>
public class ViewModelLocator
{
/// <summary>
/// Initializes a new instance of the ViewModelLocator class.
/// </summary>
public ViewModelLocator()
{
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
 
if (!SimpleIoc.Default.IsRegistered<IMarketplaceReviewService>())
{
SimpleIoc.Default.Register<IMarketplaceReviewService, MarketplaceReviewService>();
}
 
SimpleIoc.Default.Register<MainViewModel>();
}
 
public MainViewModel MainViewModel
{
get
{
return ServiceLocator.Current.GetInstance<MainViewModel>();
}
}
 
public static void Cleanup()
{
// TODO Clear the ViewModels
}
}

Em seguinda devemos implementar o MainViewModel, como podemos ver de seguida:

/// <summary>
/// This class contains properties that the main View can data bind to.
/// </summary>
public class MainViewModel : ViewModelBase
{
/// <summary>
/// The marketplace review service.
/// </summary>
private readonly IMarketplaceReviewService _marketplaceReviewService;
 
/// <summary>
/// The public application url.
/// </summary>
private readonly string _appUrl;
 
/// <summary>
/// Initializes a new instance of the <see cref="MainViewModel"/> class.
/// </summary>
/// <param name="marketplaceReviewService">
/// The marketplace review service
/// </param>
public MainViewModel(IMarketplaceReviewService marketplaceReviewService)
{
_marketplaceReviewService = marketplaceReviewService;
 
RateCommand = new RelayCommand(Rate);
}
 
/// <summary>
/// Gets the rate command.
/// </summary>
public ICommand RateCommand { get; private set; }
 
/// <summary>
/// The rate.
/// </summary>
private void Rate()
{
_marketplaceReviewService.Show();
}
}

para conetar a view model com a página devemos adicionar a ViewModelLocator no App.xaml:

<vm:ViewModelLocator x:Key="Locator" d:IsDataSource="True" />

e adicionar o binding na página principal:


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

A MainPage.xaml será algo do género:

<phone:PhoneApplicationPage x:Class="CimbalinoSample.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cimbalino="clr-namespace:Cimbalino.Phone.Toolkit.Behaviors;assembly=Cimbalino.Phone.Toolkit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
DataContext="{Binding MainViewModel,
Source={StaticResource Locator}}"

FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
Orientation="Portrait"
SupportedOrientations="Portrait"
shell:SystemTray.IsVisible="True"
mc:Ignorable="d">
 
<!-- 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="1"
Margin="0,5,12,396">
<TextBlock Margin="12,0"
Style="{StaticResource PhoneTextTitle2Style}"
Text="Cimbalino Toolkit Sample" />
</StackPanel>
<TextBlock Grid.RowSpan="2"
Margin="12,50,-3,487"
Style="{StaticResource PhoneTextTitle3Style}"
TextWrapping="Wrap">
This samples has the goal to show how to use Cimbalino Toolkit - MarketplaceReviewService
</TextBlock>
<!-- ContentPanel - place additional content here -->
<Grid x:Name="ContentPanel"
Grid.Row="1"
Margin="12,0,12,0" />
<i:Interaction.Behaviors>
<cimbalino:ApplicationBarBehavior>
<cimbalino:ApplicationBarIconButton Command="{Binding RateCommand,
Mode=OneTime}"

IconUri="/Images/appbar.rate.png"
Text="Rate it" />
</cimbalino:ApplicationBarBehavior>
</i:Interaction.Behaviors>
</Grid>
 
</phone:PhoneApplicationPage>


Exemplo Relacionado

Código Fonte

O código fonte pode ser obtido aqui.

97 page views in the last 30 days.