private void PopulateProductsLists(List <Product> productsList)
        {
            var y      = 0;
            var column = LeftColumn;
            var productTapGestureRecognizer = new TapGestureRecognizer();

            productTapGestureRecognizer.Tapped += OnProductTapped;

            for (var i = 0; i < productsList.Count; i++)
            {
                var item = new ProductGridItemTemplate();

                if (i % 2 == 0)
                {
                    column = LeftColumn;
                    y++;
                }
                else
                {
                    column = RightColumn;
                }

                item.BindingContext = new ProductViewModel(productsList[i].Id);
                item.GestureRecognizers.Add(productTapGestureRecognizer);
                column.Children.Add(item);
            }
        }
Beispiel #2
0
        private void PopulateProductsLists(List <Product> productsList)
        {
            var lastHeight = 100;
            var y          = 0;
            var column     = LeftColumn;
            var productTapGestureRecognizer = new TapGestureRecognizer();

            productTapGestureRecognizer.Tapped += OnProductTapped;

            for (var i = 0; i < productsList.Count; i++)
            {
                var item = new ProductGridItemTemplate();

                if (i > 0)
                {
                    if (i == 3 || i == 4 || i == 7 || i == 8 || i == 11 || i == 12)
                    {
                        lastHeight = 100;
                    }
                    else
                    {
                        lastHeight = 190;
                    }

                    if (i % 2 == 0)
                    {
                        column = LeftColumn;
                        y++;
                    }
                    else
                    {
                        column = RightColumn;
                    }
                }

                var viewmodel = new ProductViewModel(productsList[i].Id);
                viewmodel.ThumbnailHeight = lastHeight;
                item.BindingContext       = viewmodel;
                item.GestureRecognizers.Add(productTapGestureRecognizer);
                column.Children.Add(item);
            }
        }