【发布时间】:2013-11-28 13:15:24
【问题描述】:
以下代码在我的 windows phone 7 应用程序中显示为特定日期安排的约会列表
private void DisplayAppointmentsForDate(DateTime date)
{
appointmentsSource.FetchData(date, date.AddDays(1));
this.AppointmentsList.ItemsSource = appointmentsSource.GetAppointments((IAppointment appointment) =>
{
DateTime currentAppointmentStart = appointment.StartDate;
DateTime currentAppointmentEnd = appointment.EndDate;
DateTime requiredAppointmentsStartDate = date.Date;
DateTime requiredAppointmentsEndDate = date.Date.AddDays(1);
if (requiredAppointmentsEndDate > currentAppointmentStart && requiredAppointmentsStartDate < currentAppointmentEnd)
{
return true;
}
return false;
});
}
private void RadCalendar_SelectedValueChanged(object sender, ValueChangedEventArgs<object> e)
{
if (e.NewValue == null)
{
this.AppointmentsList.ItemsSource = null;
return;
}
DisplayAppointmentsForDate((e.NewValue as DateTime?).Value);
}
但这显示了为特定日期安排的约会。例如。如果在日历上选择了 23/09/2013,则列表将显示当天的所有约会。
我想更改此设置,以便列表显示特定月份的所有约会。例如。如果日历是 2013 年 7 月,则列表应显示该月的所有约会。
开始和结束日期都设置为 DateTime 类型,其值例如 23/09/2013 12:01PM,这就是它用于获取应用列表的方式。
我尝试过使用appointmentsSource.FetchData(date.Month, date.AddDays(1));,但它不起作用。
我该怎么做?
【问题讨论】:
-
你已经尝试过什么?特别是,您的
FetchData电话看起来就像您需要它做的一切,只要您给出一个月的开始和下个月的开始......
标签: c# xaml windows-phone-7 datetime visual-studio-2012