本文介绍了DatePickerTextBox切换日期和月份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是声明我的 DatePickerTextBox
的代码行:
This is the line of code that declares my DatePickerTextBox
:
<DatePickerTextBox Text="{Binding dateOfBirth, StringFormat=dd-MM-yyyy}" />
(注意 StringFormat = dd-MM-yyyy
)
当 DatePickerTextBox
为空时,占位符<此处输入文本> ;
,我写下来如下:
When the DatePickerTextBox
is empty with the placeholder <Enter text here>
, and I write in it something like:
01-02-0003
...点击 DatePickerTextBox
之后,显示的文本自动更改为:
...after clicking outside the DatePickerTextBox
, the displayed text automatically changes to:
02-01-0003
(即:自动切换月和一天)
如何解决这个问题?
推荐答案
由于文化差异
定义以下xml命名空间:
Define the following xml namespace:
xmlns:gl="clr-namespace:System.Globalization;assembly=mscorlib"
指定与您相关的文化信息
Specifiy the culture info relevant to you
<DatePickerTextBox Text="{Binding Path=dateOfBirth,
StringFormat=dd-MM-yyyy,
ConverterCulture={x:Static gl:CultureInfo.CurrentCulture}" />
这篇关于DatePickerTextBox切换日期和月份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!