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

Global Date Format

3 Answers 146 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
gerardo
Top achievements
Rank 1
Veteran
gerardo asked on 21 Feb 2021, 06:56 AM

I have multiple RadDateTimePicker in different forms/pages. Can I set the display format of RadDateTimePicker in styling to have it applied globally across the project? 

 

Thank you.

3 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 24 Feb 2021, 03:14 PM

Hello Gerardo,

Indeed, you can create a custom attached property and then set it via an implicit style (in your App.xaml, for example) to apply it to all RadDateTimePicker instances in your application. In the property's property changed callback you can set the desired formats of the created CultureInfo as shown in the Formatting article.

Please let me know whether such an approach would work for you.

Regards,
Dilyan Traykov
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
gerardo
Top achievements
Rank 1
Veteran
answered on 01 Mar 2021, 06:20 AM

Thank you for your response Sir.

I was able to apply the custom Date format with that approach.

I have set the DisplayFormat to Long and have a custom property Longdateformat to "dd-MMM-yyyy" and displays the value properly. 

With those property set, I can input the following and have the display format of "28-Feb-2021" 

28-feb-2021

02-28-2021

 

But when I input 28-02-2021 it displays an error. 

Is it possible to accept the 28-02-2021 since the display format is "dd-MMM-yyyy"?

0
Dilyan Traykov
Telerik team
answered on 02 Mar 2021, 02:49 PM

Hello Gerardo,

Can you please specify what CultureInfo you've set as the Culture of the control?

I tried replicating the behavior you described in a small sample project, however, the " 28-02-2021" input is parsed successfully.

Can you please have a look at the attached project and let me know how it differs from the one at your end?

Regards,
Dilyan Traykov
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/.

Tags
DateTimePicker
Asked by
gerardo
Top achievements
Rank 1
Veteran
Answers by
Dilyan Traykov
Telerik team
gerardo
Top achievements
Rank 1
Veteran
Share this question
or