Created
June 21, 2014 13:23
-
-
Save wtuts/4aa8d5454785577b983f to your computer and use it in GitHub Desktop.
in app purchase
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ObservableCollection<ProductItem> picItems = new ObservableCollection<ProductItem>(); | |
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) | |
{ | |
RenderStoreItems(); | |
base.OnNavigatedTo(e); | |
} | |
private async void RenderStoreItems() | |
{ | |
picItems.Clear(); | |
try | |
{ | |
//StoreManager mySM = new StoreManager(); | |
ListingInformation li = await Store.CurrentApp.LoadListingInformationAsync(); | |
foreach (string key in li.ProductListings.Keys) | |
{ | |
ProductListing pListing = li.ProductListings[key]; | |
System.Diagnostics.Debug.WriteLine(key); | |
string status = Store.CurrentApp.LicenseInformation.ProductLicenses[key].IsActive ? "Purchased" : pListing.FormattedPrice; | |
string imageLink = string.Empty; | |
picItems.Add( | |
new ProductItem { | |
imgLink = key.Equals("AdBlocker") ? "block-ads.png" : "block-ads.png", | |
Name = pListing.Name, | |
Status = status, | |
key = key, | |
BuyNowButtonVisible = Store.CurrentApp.LicenseInformation.ProductLicenses[key].IsActive ? System.Windows.Visibility.Collapsed : System.Windows.Visibility.Visible | |
} | |
); | |
} | |
pics.ItemsSource = picItems; | |
} | |
catch (Exception e) | |
{ | |
System.Diagnostics.Debug.WriteLine(e.ToString()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ScrollViewer HorizontalAlignment="Left" Margin="12,0,12,0" Grid.Row="1"> | |
<ItemsControl x:Name="pics"> | |
<ItemsControl.ItemTemplate> | |
<DataTemplate> | |
<StackPanel> | |
<Grid> | |
<Grid.ColumnDefinitions> | |
<ColumnDefinition Width="*"/> | |
<ColumnDefinition Width="*"/> | |
</Grid.ColumnDefinitions> | |
<Image Margin="4" Source="{Binding imgLink}"/> | |
<StackPanel Grid.Column="1" Margin="0,30,0,0"> | |
<TextBlock Foreground="white" FontWeight="ExtraBold" Text="{Binding Name}" /> | |
<TextBlock Foreground="white" FontWeight="Normal" Text="{Binding Status}" /> | |
<Button Content="Buy Now" Visibility="{Binding BuyNowButtonVisible}" Click="ButtonBuyNow_Clicked" Tag="{Binding key}" /> | |
</StackPanel> | |
</Grid> | |
</StackPanel> | |
</DataTemplate> | |
</ItemsControl.ItemTemplate> | |
</ItemsControl> | |
</ScrollViewer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ProductItem | |
{ | |
public string imgLink { get; set; } | |
public string Status { get; set; } | |
public string Name { get; set; } | |
public string key { get; set; } | |
public System.Windows.Visibility BuyNowButtonVisible { get; set; } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment