如何在 windows 8 应用程序中安排特定日期和时间的 toast 通知?
How to schedule a toast notification for a specific date and time in windows 8 app?
我想为日历应用程序的 c# 中的 windows 应用程序安排特定日期和时间的吐司通知,例如 2015 年 3 月 18 日 4:00 下午。我制作了 3 个组合框 (NewEventYear) 等等。我正在尝试的是..
int x = int.Parse(NewEventYear.SelectedItem.ToString());
/* y & z for month and date respectively */
DateTime EventDate = new DateTime(x,y,z);
ScheduledToastNotification scheduledToast = new ScheduledToastNotification(toastXml, EventDate);
我收到一个错误
"FormatException was unhandled by user code : Input string was not in
correct format"
指向
int x = int.Parse(NewEventYear.SelectedItem.ToString());
你可以使用的是
ObservableCollection<DateTime> myDateTimeCollection = new ObservableCollection<DateTime>();
myDateTimeCollection.Add(DateTime.Now); // add more members
myComboBox.ItemsSource = myDateTimeCollection;
DateTime selectedDateTime = (DateTime)myComboBox.SelectedItem; //add this in myComboBox_SelectionChanged event
感谢您的帮助。通过编写这段代码解决了我的问题。
int x = int.Parse(NewEventYear.SelectedItem.ToString());
int y = int.Parse(NewEventMonth.SelectedItem.ToString());
int z = int.Parse(NewEventDate.SelectedItem.ToString());
int a = int.Parse(NewEventHour.SelectedItem.ToString());
int b = int.Parse(NewEventMinutes.SelectedItem.ToString());
DateTime EventDate = new DateTime(x,y,z,a,b,0)
TimeSpan NotTime = EventDate.Subtract(DateTime.Now);
DateTime dueTime = DateTime.Now.Add(NotTime);
ScheduledToastNotification scheduledToast = new ScheduledToastNotification(toastXml, dueTime);
ToastNotificationManager.CreateToastNotifier().AddToSchedule(scheduledToast);
我想为日历应用程序的 c# 中的 windows 应用程序安排特定日期和时间的吐司通知,例如 2015 年 3 月 18 日 4:00 下午。我制作了 3 个组合框 (NewEventYear) 等等。我正在尝试的是..
int x = int.Parse(NewEventYear.SelectedItem.ToString());
/* y & z for month and date respectively */
DateTime EventDate = new DateTime(x,y,z);
ScheduledToastNotification scheduledToast = new ScheduledToastNotification(toastXml, EventDate);
我收到一个错误
"FormatException was unhandled by user code : Input string was not in correct format"
指向
int x = int.Parse(NewEventYear.SelectedItem.ToString());
你可以使用的是
ObservableCollection<DateTime> myDateTimeCollection = new ObservableCollection<DateTime>();
myDateTimeCollection.Add(DateTime.Now); // add more members
myComboBox.ItemsSource = myDateTimeCollection;
DateTime selectedDateTime = (DateTime)myComboBox.SelectedItem; //add this in myComboBox_SelectionChanged event
感谢您的帮助。通过编写这段代码解决了我的问题。
int x = int.Parse(NewEventYear.SelectedItem.ToString());
int y = int.Parse(NewEventMonth.SelectedItem.ToString());
int z = int.Parse(NewEventDate.SelectedItem.ToString());
int a = int.Parse(NewEventHour.SelectedItem.ToString());
int b = int.Parse(NewEventMinutes.SelectedItem.ToString());
DateTime EventDate = new DateTime(x,y,z,a,b,0)
TimeSpan NotTime = EventDate.Subtract(DateTime.Now);
DateTime dueTime = DateTime.Now.Add(NotTime);
ScheduledToastNotification scheduledToast = new ScheduledToastNotification(toastXml, dueTime);
ToastNotificationManager.CreateToastNotifier().AddToSchedule(scheduledToast);