有没有办法让Reminder
一个自定义的重复间隔工作,比如每 4 小时?因为现在我知道的唯一选择是将 设置RecurrenceType
为RecurrenceInterval
,它只支持每日、每周、每月和每年的重复。
问问题
545 次
2 回答
2
您可以通过这种方式在每 4 小时内重复提醒特定时间:
private int _intervalHours;
public int IntervalHours
{
get
{
return _intervalHours;
}
set
{
_intervalHours = value;
RaisePropertyChanged("IntervalHours");
}
}
private int _frequency;
public int Frequency
{
get
{
return _frequency;
}
set
{
_frequency = value;
RaisePropertyChanged("Frequency");
}
}
//RecurrenceInterval.None is used as a new reminder will be created for every 4 hours in your case
RecurrenceInterval recurrence = RecurrenceInterval.None;
//inserting staring reminder
name = System.Guid.NewGuid().ToString();
reminder = new Reminder(name);
reminder.RecurrenceType = recurrence;
reminder.Title = title;
reminder.Content = content;
reminder.BeginTime = beginTime;
reminder.ExpirationTime = expirationTime;
reminder.RecurrenceType = recurrence;
reminder.NavigationUri = navigationUri;
ScheduledActionService.Add(reminder);
//inserting reminder for IntervalHours, let say at interval of 4 hours and will added after each IntervalHours upto Frequency(number of time)
if (IntervalHours > 0)
{
//i is started from 1 as 1 reminder added above
for (int i = 1; i < Frequency; i++)
{
name = System.Guid.NewGuid().ToString();
reminder = new Reminder(name);
reminder.RecurrenceType = recurrence;
reminder.Title = title;
reminder.Content = content;
reminder.BeginTime = beginTime.AddHours(IntervalHours*i);
reminder.ExpirationTime = expirationTime.AddHours(IntervalHours*i);
reminder.RecurrenceType = recurrence;
reminder.NavigationUri = navigationUri;
ScheduledActionService.Add(reminder);
}
}
希望这会有所帮助。
于 2014-01-02T14:59:29.723 回答
-1
目前在 WP8 中它不支持。
于 2013-12-22T07:21:47.923 回答