New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTimePicker - Format #2622

Closed
pavelkocich opened this Issue Aug 25, 2016 · 7 comments

Comments

Projects
None yet
5 participants
@pavelkocich

pavelkocich commented Aug 25, 2016

It will be great if I can set DateTime format of string shown in DataPickerTextbox.

  • MahApps.Metro __v1.3.0-ALPHA189
  • Windows 10
  • Visual Studio 2015
  • .NET Framework 4.5
@stanleyipc

This comment has been minimized.

stanleyipc commented Aug 31, 2016

Can you be more specific?

@xxMUROxx

This comment has been minimized.

Contributor

xxMUROxx commented Sep 5, 2016

Set Culture property. DateTimeFormat property is also not present on DatePicker

@pavelkocich

This comment has been minimized.

pavelkocich commented Sep 7, 2016

I can set Culture property of course, but it will be great to have more straightforward solution with property e.g. StringFormat, like Label control.

<Label ContentStringFormat="dd.MM.yyyy hh:mm" Content="{Binding MyDateTime}"/>

<controls:DateTimePicker StringFormat="dd.MM.yyyy hh:mm" SelectedDate="{Binding MyDateTime}" />

@anders9ustafsson

This comment has been minimized.

anders9ustafsson commented Apr 18, 2017

Since this feature still is not implemented, are there any quick fixes that I could use instead? For example, I am using Culture sv-SE which gives me a date-time format yyyy-MM-dd HH:mm:ss. However, I don't want to display the seconds. Is there any way I can accomplish this using the Culture property only?

@punker76

This comment has been minimized.

Member

punker76 commented Apr 18, 2017

@anders9ustafsson As a workaround you can override the time pattern with at a custom CultureInfo, cause the DateTimePicker uses this to format the text

var dateTimeFormat = string.Intern($"{formatInfo.ShortDatePattern} {formatInfo.LongTimePattern}");

e.g.

var ci = new CultureInfo("sv-SE");
ci.DateTimeFormat.LongTimePattern = ci.DateTimeFormat.ShortTimePattern;

then set this to the Culture property of the DateTimePicker.

/cc @xxMUROxx This should be easier to do in future release...

@anders9ustafsson

This comment has been minimized.

anders9ustafsson commented Apr 18, 2017

@punker76 Thanks for the suggestion! I'll try it out.

@xxMUROxx

This comment has been minimized.

Contributor

xxMUROxx commented Apr 18, 2017

@punker76 I will provide a PR soon

@xxMUROxx xxMUROxx referenced this issue Apr 18, 2017

Merged

DisplayFormat in DateTimePicker and TimePicker #2930

3 of 3 tasks complete

xxMUROxx added a commit to xxMUROxx/MahApps.Metro that referenced this issue Apr 18, 2017

Add SelectedDateFormat DependencyProperty to DateTimePicker
Add SelectedTimeFormat to TimePickerBase

Closes MahApps#2622

@punker76 punker76 added this to the 1.6.0 milestone May 15, 2017

@punker76 punker76 added the Bug label Feb 11, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment