private void SetFont(ExtendedEntry entry)
 {
     if (!String.IsNullOrWhiteSpace(entry.FontName)) {
         var font = UIFont.FromName (entry.FontName, (nfloat)entry.FontSize);
         if (font != null)
         {
             this.Control.Font = font;
         }
     } else {
         this.Control.Font = Font.Default.ToUIFont().WithSize((nfloat)entry.FontSize);
     }
 }
 private void SetFont(ExtendedEntry entry)
 {
     string filename = entry.FontName;
     if (!String.IsNullOrWhiteSpace(filename)) {
         //if no extension given then assume and add .ttf
         if(filename.LastIndexOf(".", System.StringComparison.Ordinal) != filename.Length - 4)
         {
             filename = string.Format("{0}.ttf", filename);
         }
         Control.Typeface = TrySetFont(filename);
     } else {
         Control.Typeface = Typeface.Default;
     }
 }
 //Workaround for bug #1
 private void ResetPlaceholderFont(ExtendedEntry entry)
 {
     this.Control.Font = Font.Default.ToUIFont().WithSize((nfloat)entry.FontSize);
     SetFont (entry);
 }
        private void InitFloatingLabel()
        {
            this.StatesProperties = new Dictionary<FloatingLabelEntryState, FloatingLabelEntryStateProperties> ();
            this.Padding = new Thickness (0, 0, 0, 0);
            this.HasShadow = false;

            this._DisplayView=new ContentView();
            this._ActivityIndicator= new ActivityIndicator { IsRunning=false};
            this.Icon = new Image ();

            this._InfoMessage=new ExtendedLabel {
                Text=this.InfoMessage,
                VerticalTextAlignment=TextAlignment.End,
                VerticalOptions=LayoutOptions.CenterAndExpand,
                HorizontalTextAlignment=TextAlignment.Center,
                HorizontalOptions=LayoutOptions.FillAndExpand,
                TextColor=this.TextColor,
            };
            _InfoMessage.SetBinding (Label.TextProperty, FloatingLabelEntryBase.InfoMessageProperty.PropertyName);
            _InfoMessage.SetBinding (VisualElement.BackgroundColorProperty, VisualElement.BackgroundColorProperty.PropertyName);
            _InfoMessage.SetBinding (ExtendedLabel.FontNameProperty, FontNamePropertyName);
            _InfoMessage.SetBinding (Label.TextColorProperty, TextColorPropertyName);

            _InfoMessage.BindingContext = this;

            _Label = new ExtendedLabel {
                Text=this.LabelText,
                Opacity=0,
                TextColor=this.TextColor,
            };
            _Label.SetBinding (Label.TextProperty, LabelTextPropertyName);
            _Label.SetBinding (Label.BackgroundColorProperty, FloatingLabelEntryBase.BackgroundColorProperty.PropertyName);
            _Label.SetBinding (ExtendedLabel.FontNameProperty, FontNamePropertyName);
            _Label.SetBinding (ExtendedLabel.TextColorProperty, TextColorPropertyName);

            _Label.BindingContext = this;

            _Entry = new ExtendedEntry () {
                IsPassword=this.IsPassword,
                Text=this.EntryText,
                FontName=this.FontName,
            } ;
            _Entry.SetBinding (ExtendedEntry.TextProperty, EntryTextPropertyName);
            _Entry.SetBinding (ExtendedEntry.PlaceholderProperty, LabelTextPropertyName);
            _Entry.SetBinding (ExtendedEntry.IsPasswordProperty, IsPasswordPropertyName);
            _Entry.SetBinding (ExtendedEntry.CustomKeyboardProperty, CustomKeyboardPropertyName);
            _Entry.SetBinding (ExtendedEntry.FontNameProperty, FontNamePropertyName);
            _Entry.SetBinding (ExtendedEntry.BackgroundColorProperty, FloatingLabelEntryBase.BackgroundColorProperty.PropertyName);
            _Entry.SetBinding (ExtendedEntry.TextColorProperty, TextColorPropertyName);

            _Entry.BindingContext = this;

            this._Entry.Focused+=((s, e) => {
                this._Label.Opacity=1;
                this._Entry.Placeholder=string.Empty;
            });

            this._Entry.Unfocused+=((s, e) => {
                if (String.IsNullOrWhiteSpace(this._Entry.Text)) {
                    this._Label.Opacity=0;
                    this._Entry.Text=null;
                    this._Entry.Placeholder=this.LabelText;
                    reset();
                }
                else {
                    if (MustValidate) {
                        Device.BeginInvokeOnMainThread(()=>this.SetActivityRunning(true));
                        validate(()=> this.SetActivityRunning(false));
                    }
                }
            });
            DoLayout ();
        }