WPF 工具包 DateTimePicker 提供格式不正确的值
WPF toolkit DateTimePicker giving incorrectly formated value
我正在尝试获取 dd/MM/yyyy hh:mm:ss tt
格式的 DateTimePicker
值。DateTimePicker
代码是
<xctk:DateTimePicker x:Name="startDateTimePicker" Value="{Binding SelectedDate}"
FormatString="dd/MM/yyyy hh:mm:ss tt" Width="280" Height="30" Watermark="Select DateTime"/>
我已经提到了我想要的格式字符串,但它给我的输出是 MM/dd/yyyy hh:mm:ss tt
。不明白为什么会这样。我的系统日期时间是 MM/dd/yyyy
会影响结果。如果是,我该如何取消它。
您应该将 Format
属性 设置为 Custom
以应用 FormatString
。
试试这个:
<xctk:DateTimePicker x:Name="startDateTimePicker" Value="{Binding SelectedDate}"
Format="Custom"
FormatString="dd\/MM\/yyyy hh:mm:ss tt" Width="280" Height="30" Watermark="Select DateTime"/>
我正在尝试获取 dd/MM/yyyy hh:mm:ss tt
格式的 DateTimePicker
值。DateTimePicker
代码是
<xctk:DateTimePicker x:Name="startDateTimePicker" Value="{Binding SelectedDate}"
FormatString="dd/MM/yyyy hh:mm:ss tt" Width="280" Height="30" Watermark="Select DateTime"/>
我已经提到了我想要的格式字符串,但它给我的输出是 MM/dd/yyyy hh:mm:ss tt
。不明白为什么会这样。我的系统日期时间是 MM/dd/yyyy
会影响结果。如果是,我该如何取消它。
您应该将 Format
属性 设置为 Custom
以应用 FormatString
。
试试这个:
<xctk:DateTimePicker x:Name="startDateTimePicker" Value="{Binding SelectedDate}"
Format="Custom"
FormatString="dd\/MM\/yyyy hh:mm:ss tt" Width="280" Height="30" Watermark="Select DateTime"/>