Ejemplo n.º 1
0
        private View HeightEntryView()
        {
            var lblTitle = new Label()
            {
                FontSize  = Sizes.TextMicro,
                Text      = "HØYDE:",
                TextColor = Colors.TextFaded,
            };

            var entry = new Entry()
            {
                HorizontalOptions   = LayoutOptions.Start,
                VerticalOptions     = LayoutOptions.Center,
                BackgroundColor     = Color.Transparent,
                FontSize            = Sizes.TextLarge,
                Keyboard            = Keyboard.Numeric,
                MaxLength           = 3,
                IsSpellCheckEnabled = false,
                WidthRequest        = 100,
            };

            entry.SetBinding(Entry.TextProperty, nameof(ViewModel.Height));

            var lblUnit = new Label()
            {
                HorizontalOptions = LayoutOptions.EndAndExpand,
                VerticalOptions   = LayoutOptions.Center,
                FontSize          = Sizes.TextLarge,
                Text = "cm",
            };

            var unitLayout = new StackLayout()
            {
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Center,
                Spacing           = 1,
                Orientation       = StackOrientation.Horizontal,
                Children          =
                {
                    entry,
                    lblUnit,
                }
            };

            unitLayout.AddTouch((sender, args) =>
            {
                entry.Focus();
            });

            return(new StackLayout()
            {
                Spacing = Device.RuntimePlatform == Device.Android ? -5 : 0,
                Children =
                {
                    lblTitle,
                    unitLayout,
                }
            });
        }