Hello,
You can create a custom Entry, detect the input characters, if the input format is correct and convert it to the MM/dd/yyyy
format.
public class MyEntry : Entry
{
public MyEntry(){
}
protected override void OnTextChanged(string oldValue, string newValue)
{
base.OnTextChanged(oldValue, newValue);
DateTime date;
if (newValue != null)
{
if (DateTime.TryParseExact(newValue, "MMddyyyy", null, System.Globalization.DateTimeStyles.None, out date))
{
this.Text = date.ToString("MM/dd/yyyy");
//Console.WriteLine();
}
else
{
Console.WriteLine("The number entered is not a valid date format!");
}
}
}
You can use it in the layout like following code.
<local:MyEntry Keyboard="Numeric"></local:MyEntry>
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.