Xamarin.Forms.DatePicker Text Color

For Xamarin.Forms.DatePicker It is not obvious that the date field is "tapable". I want to change the color of the text to blue so the user can think it is clickable?

I see the background color property but not the forecolor / text color?

Let me know how I can do this.

+3


source to share


2 answers


I don't think the forecolor / text color is available at this time, and I'm not sure if it will be in the future or not. Typically, in this scenario, you must create a Custom Renderer to go into the native implementation of the iOS UIDatePicker control and change its properties there. The problem with this in this case is that if you go through the iOS SDK documentation, I don't think there is a way to customize the text in the UIDatePicker control. This is why you cannot do this in Xamarin.Forms either.



At this point, you may have to create your own custom control / render control to make such a small change. Disappointing, I know, but unfortunately at this point I don't think you can actually accomplish the simple thing you want to do. :-(

+4


source


I just created a class like this in my Android project and didn't make any changes to my form pages:



using Xamarin.Forms;

using xxxx.Droid;

[assembly: ExportRenderer(typeof(Xamarin.Forms.DatePicker), typeof(MyDatePickerRederer))]

namespace xxxx.Droid
{
   public class MyDatePickerRederer :    Xamarin.Forms.Platform.Android.DatePickerRenderer
   {
    protected override void OnElementChanged(Xamarin.Forms.Platform.Android.ElementChangedEventArgs<Xamarin.Forms.DatePicker> e)
    {
        base.OnElementChanged(e);

        this.Control.SetTextColor(Android.Graphics.Color.Black);
    }
   }
} 

      

+5


source







All Articles