protected override void OnElementChanged(ElementChangedEventArgs <Label> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement != null)
            {
                View = (MeasuredLabel)e.NewElement;

#if __ANDROID__
#elif __IOS__
                Control.Lines = View.NumberOfLines;
#endif
                Measure();

                View.TextUpdate += (sender, args) =>
                {
                    Measure();
                };
            }
        }
Пример #2
0
        public NavigationBar()
        {
            Console.WriteLine(Device.RuntimePlatform);

            BackgroundColor = Colors.CartoNavyLight;

            statusbar = new BaseView {
                BackgroundColor = Colors.CartoNavyLight
            };
            container = new BaseView();

            Title                         = new MeasuredLabel();
            Title.TextColor               = Color.White;
            Title.FontAttributes          = FontAttributes.Bold;
            Title.VerticalTextAlignment   = TextAlignment.Center;
            Title.HorizontalTextAlignment = TextAlignment.Center;
            Title.FontSize                = 14;
            Title.NumberOfLines           = 1;

            field = new BaseEntry();
            field.BackgroundColor    = Colors.CartoNavyLight;
            field.TextColor          = Title.TextColor;
            field.FontSize           = Title.FontSize;
            field.AutoCorrectEnabled = false;
            field.FontAttributes     = Title.FontAttributes;
            field.IsVisible          = false;

            Back = new NavigationBackButton();

            Edit = new TitleEditButton();

            Title.Measured += delegate
            {
                double x = Width / 2 - Title.MeasuredWidth / 2;

                Title.UpdateLayout(x, BaseY, Title.MeasuredWidth, Height - BaseY);
                Edit.UpdateX(x + Title.MeasuredWidth);
            };
        }