我们的日期格式为DD / MM / YYYY。如果用户仅输入日期和月份,则该应用应自动获取当前年份。例如:如果用户放置0104,则该应用应获取01/04/2020。需要根据日期自动获得年份
如果用户在DatePicker ddmm(ex.0401)上选择Date,则应当自动以dd / mm / yyyy格式(例如ex.04 / 01/2020)获得Date]
<DatePicker
Grid.Column="3"
x:Name="FinancialYear"
HorizontalAlignment="Left"
Margin="74,317,0,0"
VerticalAlignment="Top"
SelectedDate="{Binding FinancialYear,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged,StringFormat='dd/MM/yyyy',ValidatesOnDataErrors=False}"
Uid="none" Width="151"
PreviewKeyDown="FinancialYear_PreviewKeyDown">
</DatePicker>
<DatePicker x:Name="FinancialYear">
<DatePicker.Resources>
<Style TargetType="{x:Type DatePickerTextBox}">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<TextBox x:Name="PART_TextBox" Text="{Binding Path=SelectedDate, StringFormat='dd MM',
RelativeSource={RelativeSource AncestorType={x:Type DatePicker}}}" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</DatePicker.Resources>
</DatePicker>