protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.DatePicker> e) { base.OnElementChanged(e); if (e.OldElement == null) { Control.Background = null; string fontFamily = e.NewElement?.FontFamily; if (!string.IsNullOrEmpty(fontFamily)) { var label = (TextView)Control; // for example Typeface font = Typeface.CreateFromAsset(Forms.Context.Assets, fontFamily + ".otf"); label.Typeface = font; } var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; Control.LayoutParameters = layoutParams; Control.SetPadding(0, 0, 0, 0); SetPadding(0, 0, 0, 0); BorderlessDatePicker element = Element as BorderlessDatePicker; if (!string.IsNullOrWhiteSpace(element.Placeholder)) { Control.Text = element.Placeholder; } this.Control.TextChanged += (sender, arg) => { var selectedDate = arg.Text.ToString(); if (selectedDate == element.Placeholder) { Control.Text = DateTime.Now.ToString("dd/MM/yyyy"); } }; } }
protected override void OnElementChanged(ElementChangedEventArgs <DatePicker> e) { base.OnElementChanged(e); if (e.OldElement == null) { Control.Background = null; var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; Control.LayoutParameters = layoutParams; Control.SetPadding(0, 0, 0, 0); SetPadding(0, 0, 0, 0); BorderlessDatePicker element = Element as BorderlessDatePicker; if (element.Date == element.MinimumDate && !String.IsNullOrEmpty(element.Placeholder)) { Control.Text = element.Placeholder; textColor = element.TextColor; placeholderColor = element.PlaceholderColor == default(Color) ? textColor : element.PlaceholderColor; element.TextColor = placeholderColor; Control.Click += Control_Click; } } }
//public BorderlessDatePickerRender(Context context) : base(context) //{ //} protected override void OnElementChanged(ElementChangedEventArgs <DatePicker> e) { base.OnElementChanged(e); // this.Control.SetTextColor(Android.Graphics.Color.Rgb(83, 63, 149)); this.Control.SetBackgroundColor(Android.Graphics.Color.Transparent); this.Control.SetPadding(20, 0, 0, 0); //GradientDrawable gd = new GradientDrawable(); //gd.SetCornerRadius(25); //increase or decrease to changes the corner look //gd.SetColor(Android.Graphics.Color.Transparent); //gd.SetStroke(3, Android.Graphics.Color.Rgb(83, 63, 149)); //this.Control.SetBackgroundDrawable(gd); BorderlessDatePicker element = Element as BorderlessDatePicker; if (!string.IsNullOrWhiteSpace(element.Placeholder)) { Control.Text = element.Placeholder; } this.Control.TextChanged += (sender, arg) => { var selectedDate = arg.Text.ToString(); if (selectedDate == element.Placeholder) { Control.Text = DateTime.Now.ToString("dd/MM/yyyy"); } }; }
private void Dialog_DateSet(object sender, DateSetEventArgs e) { BorderlessDatePicker element = Element as BorderlessDatePicker; element.Date = e.Date; if (Control.Text == element.Placeholder) { Control.Text = element.Date.ToString(Element.Format); element.TextColor = textColor; } }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.DatePicker> e) { base.OnElementChanged(e); element = (BorderlessDatePicker)this.Element; if (e.OldElement == null && !string.IsNullOrEmpty(element.Image)) { Control.Background = null; var layoutParams = new MarginLayoutParams(Control.LayoutParameters); layoutParams.SetMargins(0, 0, 0, 0); LayoutParameters = layoutParams; Control.LayoutParameters = layoutParams; Control.SetPadding(0, 0, 0, 0); SetPadding(0, 0, 0, 0); Control.Background = AddPickerStyles(element.Image); } }