在我的UWP C#应用程序中,我想在TextBlock中显示当前选择的CalendarView日期,我知道我应该使用SelectedDatesChanged事件来更新TextBlock,但我找不到任何代码来获取和解析日期。
答案 0 :(得分:1)
您可以使用args.AddedDates
从SelectedDatesChanged
活动
private void CalendarView_SelectedDatesChanged(CalendarView sender, CalendarViewSelectedDatesChangedEventArgs args)
{
var myDate = args.AddedDates.First(); //Since args.AddedDates returns collection we should use First to get the first item
MyTextBlock.Text = myDate.ToString(); //You can convert DateTime into different format using myDate.ToString(format);
}
要详细了解Use patterns to format dates and times,DateTimeOffset.ToString Method