System.ArgumentException:值不在预期范围内。在WindowsPhone应用程序中

时间:2015-05-04 10:57:43

标签: c# windows-runtime windows-phone windows-phone-8.1

我正在编写 Windows Phone 8.1应用程序(WINRT)。

else if (GetProductByCategoryResultObject.Status == "1") //status is 1
                            {
                                //TODO:

                                //ProductsListingObject


                                ListView ProuctListView = new ListView();
                                ProductsListing ProductsListingObject = new ProductsListing();

                                for (int i = 0; i < GetProductByCategoryResultObject.Products.Count;i++ )
                                {

                                    ProductsListingObject.ProductsListingLabel.Text = GetProductByCategoryResultObject.Products[i].ProductName;

                                    if (GetProductByCategoryResultObject.Products[i].ProductThumbnail != null || GetProductByCategoryResultObject.Products[i].ProductThumbnail != "")
                                    {
                                        ProductsListingObject.ProductsListingImage.Source = new BitmapImage(new Uri(GetProductByCategoryResultObject.Products[i].ProductThumbnail,UriKind.Absolute));

                                    }

                                    ProuctListView.Items.Add(ProductsListingObject);

                                }

                                Grid GridObject = new Grid();
                                GridObject.Children.Add(ProuctListView);
                                (MainPagePivot.SelectedItem as PivotItem).Content = GridObject;
    }

如果 GetProductByCategoryResultObject.Products.Count (产品数量)为1,那么应用程序运行正常。但如果计数超过1.它给我错误: {System.ArgumentException:值不在预期范围内。

1 个答案:

答案 0 :(得分:0)

io.Writer