我有一个绑定到 DateTime 的 WPF 标签,我需要它从 1/1/1 开始。当设置为 1/1/1 时,标签根本不出现。如果我更改任何数字,它会在年份 (1/2/0001) 前面显示前导零。在我使用 WinForms 之前,所有这些都运行良好。
有人知道在设置为 1/1/1 时如何显示标签和/或如何去掉前导零吗?
另外,由于我想使用虚构的时间,有没有其他我可以尝试的方法可能更合适?
DateTime _date = new DateTime(1, 1, 1);
public DateTime Date
{
get { return _date; }
set
{
if (_date != value)
{
_date = value;
RaisePropertyChanged(() => Date);
}
}
}
从我的 XAML
Label Content="{Binding Date}" Style="{DynamicResource SimpleLabel}" FontFamily="Pericles" FontSize="16" VerticalAlignment="Top" HorizontalAlignment="Left"/