如何在WP8.1中发现应用内购买价格?

时间:2015-11-20 15:45:02

标签: windows-phone-8.1 windows-phone in-app-purchase winrt-xaml

在导航到确认应用内购买之前,有没有办法发现应用内购买价格?我想在自定义界面中将价格放在我的应用中。我想通过Windows Phone Store或In-App Purchase API动态获取价格。

1 个答案:

答案 0 :(得分:2)

 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("molostickerdummy") ? "/Res/41.png" : "/Res/18.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());
}