void SetLayoutStatus(List <OrderStatus> orderStatus) { List <OrderStatus> arrImage = orderStatus.Where(g => g.Id == 1 || g.Id == 2 || g.Id == 3 || g.Id == 4 || g.Id == 5 || g.Id == 11).ToList <OrderStatus>(); OrderStatus orderStatus1 = arrImage.Single(g => g.Id == 1); orderStatus1.Icon = Device.OnPlatform("Login/clock_lk_.png", "clock_lk.png", "clock_lk.png"); orderStatus1.Index = 1; OrderStatus orderStatus2 = arrImage.Single(g => g.Id == 2); orderStatus2.Icon = Device.OnPlatform("Login/pay_lk_.png", "money.png", "money.png"); orderStatus2.Index = 2; OrderStatus orderStatus3 = arrImage.Single(g => g.Id == 3); orderStatus3.Icon = Device.OnPlatform("Login/dostavka_lk_.png", "oplachen.png", "oplachen.png"); orderStatus3.Index = 3; OrderStatus orderStatus4 = arrImage.Single(g => g.Id == 4); orderStatus4.Icon = Device.OnPlatform("Login/dostavka_lk_.png", "dostavka.png", "dostavka.png"); orderStatus4.Index = 4; OrderStatus orderStatus5 = arrImage.Single(g => g.Id == 5); orderStatus5.Icon = Device.OnPlatform("Login/dostavka_lk_.png", "Dostavlen.png", "Dostavlen.png"); orderStatus5.Index = 5; OrderStatus orderStatus11 = arrImage.Single(g => g.Id == 11); orderStatus11.Icon = Device.OnPlatform("Login/sborka_lk_.png", "sborka.png", "sborka.png"); orderStatus11.Index = 11; arrImage = arrImage.OrderBy(g => g.Index).ToList <OrderStatus>(); // Grid gridStatusOrder = new Grid { // HeightRequest = 170, // RowSpacing = 1, // ColumnSpacing = 1, // BackgroundColor = ApplicationStyle.LineColor, // RowDefinitions = { // new RowDefinition { Height = new GridLength (50, GridUnitType.Star) }, // new RowDefinition { Height = new GridLength (50, GridUnitType.Star) }, // }, // ColumnDefinitions = { // new ColumnDefinition { Width = new GridLength (50, GridUnitType.Star) }, // new ColumnDefinition { Width = new GridLength (50, GridUnitType.Star) } // } // }; for (int i = 0; i < arrImage.Count; i++) { Image img = new Image { Source = arrImage[i].Icon, HeightRequest = Utils.GetSize(36), }; Label lblCount = new Label { VerticalOptions = LayoutOptions.CenterAndExpand, TextColor = ApplicationStyle.GreenColor, Text = arrImage[i].Count.ToString(), }; StackLayout layoutHorizontal = new StackLayout { HorizontalOptions = LayoutOptions.CenterAndExpand, Orientation = StackOrientation.Horizontal, Children = { img, lblCount } }; Label lblName = new Label { HorizontalOptions = LayoutOptions.CenterAndExpand, TextColor = ApplicationStyle.TextColor, Text = arrImage[i].Name, }; StackLayout layoutVertical = new StackLayout { //Padding = new Thickness(0, 14, 0, 0), Padding = new Thickness(0), BackgroundColor = Color.White, Children = { layoutHorizontal, lblName } }; //int left = i % 2 < 1 ? (i % 2) : (i % 2 + 1); //int top = i / 2 < 1 ? (i / 2) : (i / 2 + 1); int left = i % 2 < 1 ? (i % 2) : (i % 2 + 1); int top = (i / 2) * 2; TapGestureRecognizer tapStatus = new TapGestureRecognizer(); tapStatus.Tapped += OnSelectBtnStatusOrder; tapStatus.CommandParameter = arrImage [i]; layoutVertical.GestureRecognizers.Add(tapStatus); gridStatusOrder.Children.Add(layoutVertical, left, top); } gridStatusOrder.Children.Add(new BoxView(), 1, 0); gridStatusOrder.Children.Add(new BoxView(), 1, 2); gridStatusOrder.Children.Add(new BoxView(), 1, 4); gridStatusOrder.Children.Add(new BoxView(), 0, 1); gridStatusOrder.Children.Add(new BoxView(), 2, 1); gridStatusOrder.Children.Add(new BoxView(), 0, 3); gridStatusOrder.Children.Add(new BoxView(), 2, 3); }