为 TimePicker 设置 24 小时制时间格式 [英] Set 24-hour time format for TimePicker
问题描述
我正在使用
请注意,它以 24 小时格式正确显示时间.但是,当您选择该时间并返回该字段时,它会将其显示为非 24 小时制时间,并带有 AM/PM:
有没有办法强制控件以24小时格式显示时间?谢谢.
从 1.5 开始,您不能明确强制执行它:
您可以使用 SelectedTimeFormat (long/short) 例如
但是,这会选择 Windows 区域设置短/长格式,因此它取决于本地 PC.
我想我可以为将来的版本添加覆盖...
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.
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...
这篇关于为 TimePicker 设置 24 小时制时间格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!