Exemplo n.º 1
0
        protected void GeraLayout()
        {
            foreach (var item in Priorities.PrioritiesValues())
            {
                var _stackLayout = new StackLayout {
                    Spacing = 10, Orientation = StackOrientation.Horizontal
                };
                //0
                string path = ((Device.RuntimePlatform == Device.UWP) ? @"Resources/" + item.Key.ToString() + ".png" : item.Key.ToString() + ".png");
                var    imageBtnPrioritie = new Image
                {
                    Source          = path,
                    VerticalOptions = LayoutOptions.Center,
                    HeightRequest   = 30,
                    WidthRequest    = 40,
                };
                //1
                var _label = new Label {
                    Text = item.Value, HorizontalOptions = LayoutOptions.FillAndExpand, TextColor = Color.Black, Margin = new Thickness(0, 10, 0, 0)
                };

                //2
                var _idPrioritie = new Label {
                    Text = item.Key.ToString().Trim(), HorizontalOptions = LayoutOptions.FillAndExpand, TextColor = Color.Black, Margin = new Thickness(0, 0, 0, 10), IsVisible = false
                };

                var tapGestureRecognizer = new TapGestureRecognizer();
                tapGestureRecognizer.Tapped += TapedPrioritie;

                _stackLayout.Children.Add(imageBtnPrioritie);              //0
                _stackLayout.Children.Add(_label);                         //1
                _stackLayout.Children.Add(_idPrioritie);                   //2

                _stackLayout.GestureRecognizers.Add(tapGestureRecognizer); //add event

                SLPriorities.Children.Add(_stackLayout);
            }
        }