Set 24-hour time format for TimePicker

放肆的年华 提交于 2019-12-08 02:48:03

问题


I'm building an MVVM Light WPF app in Visual Studio 2015 using the Material Design in XAML Toolkit. Here's the TimePicker control:

<materialDesign:TimePicker Is24Hours="True" />

Here's what the control looks like when you click it:

Note that it shows the time in 24-hour format correctly. However, when you select that time and return to the field, it displays it as non-24-hour time, with AM/PM:

Is there any way to force the control to display the time in 24-hour format? Thanks.


回答1:


As of 1.5 you can't explicitly enforce it:

You can use SelectedTimeFormat (long/short) e.g.

<materialDesign:TimePicker Is24Hours="True" SelectedTimeFormat="Long" />

But, this picks up the Windows regional setting short/long formats, so it depends on the local PC.

I guess I can add an override for a future release...



来源:https://stackoverflow.com/questions/37141002/set-24-hour-time-format-for-timepicker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!