This is a migrated thread and some comments may be shown as answers.

TKDataFormDatePickerEditor on iOS 14

2 Answers 24 Views
DataForm - Xamarin.iOS
This is a migrated thread and some comments may be shown as answers.
Rodrigo
Top achievements
Rank 1
Veteran
Rodrigo asked on 16 Nov 2020, 09:05 PM

Date picker on iOS behaves and looks stangelly. Please see screenshot attached of the Example app provided in the latest available package Telerik_UI_for_Xamarin_2020_3_1106_1_Dev

2 Answers, 1 is accepted

Sort by
0
Accepted
Didi
Telerik team
answered on 17 Nov 2020, 06:16 AM

Hi Rodrigo,

The look of the native Date Picker for Xamarin is changed. The behavior with the Date and Time pickers is reported to the Xamarin.Forms. You can find the logged Bug report in the Xamarin.Forms GitHub repo:

https://github.com/xamarin/Xamarin.Forms/issues/12258 

Solution:

If you want to return the old look of the date picker and time picker you need a custom renderer. Here is the solution: https://github.com/xamarin/Xamarin.Forms/issues/12258#issuecomment-700168665  

So you will need to create a custom renderer for the RadDataForm control on iOS and set PreferredDatePickerStyle = UIDatePickerStyle.Wheels for the TKDataFormDatePicker and TKDataFormTimePicker(if it is used) editors. 

Create a class inside the iOS project, for example, MyCustomRenderer that inherits from DataFormRenderer

Here is the renderer implementation for iOS:

using App4.iOS;
using Telerik.XamarinForms.Input.DataForm;
using Telerik.XamarinForms.InputRenderer.iOS;
using TelerikUI;
using UIKit;
using Xamarin.Forms;

[assembly: ExportRenderer(typeof(Telerik.XamarinForms.Input.RadDataForm), typeof(MyCustomRenderer))]

namespace App4.iOS
{
    public class MyCustomRenderer : DataFormRenderer
    {
        protected override void InitEditor(TKDataFormEditor editor, IEntityProperty property)
        {
            base.InitEditor(editor, property);

            var dateeditor = (editor as TKDataFormDatePickerEditor);
            if (dateeditor == null)
                return;
            dateeditor.DatePicker.PreferredDatePickerStyle = UIDatePickerStyle.Wheels;


            var timeEditor = (editor as TKDataFormTimePickerEditor);
            if (timeEditor == null)
                return;
            timeEditor.DatePicker.PreferredDatePickerStyle = UIDatePickerStyle.Wheels;
        }
    }
}

Regards,
Didi
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

0
Rodrigo
Top achievements
Rank 1
Veteran
answered on 17 Nov 2020, 08:26 PM

Thank you for the hint. It worked. In native iOS app I had to use in the TKDataFormDelegate.UpdateEditor method:

public class CustomizationDelegate : TKDataFormDelegate
{

public override void UpdateEditor(TKDataForm dataForm, TKDataFormEditor editor, TKEntityProperty property)
{

if (editor is TKDataFormDatePickerEditor dateEditor)
{
dateEditor.DatePicker.PreferredDatePickerStyle = UIDatePickerStyle.Wheels;

}}}

Tags
DataForm - Xamarin.iOS
Asked by
Rodrigo
Top achievements
Rank 1
Veteran
Answers by
Didi
Telerik team
Rodrigo
Top achievements
Rank 1
Veteran
Share this question
or