2011-10-10 377 views
0

希望你能幫助以下。 我已經創建了提醒,但我想在提醒nofiticaton激活之前或之後對其進行更新。這裏的代碼。 問題:即使此代碼沒有編譯錯誤,它也不會工作。可以提醒更新爲Windows手機

 

var Myreminders = ScheduledActionService.GetActions() 
       .Where(a => a.BeginTime.Month == month); 


      foreach (Reminder r in Myreminders) 
      { 
       string strMyRmd; 

       strMyRmd = r.Name.ToString(); 

       if (strMyRmd == "MyName1") 
       { 
        r.Title = "Today Shopping"; 
       }    

      } 
 

感謝

+0

你的意思是,「它不工作,**和**沒有編譯錯誤」? 「不起作用」是什麼意思? –

+0

錯字錯誤。我編輯了我的信息。我的意思是,即使代碼沒有編譯錯誤,它也不會工作,因此它會被更新。 – MilkBottle

回答

0

我相信(我無法從我的計算機來測試這一點,但已經證實了這一點可與後臺代理),你需要找到你的提醒,從預定的行動服務,更新刪除並重新添加它。

var reminder = (Reminder)ScheduledsActionService.Find("MyReminder"); 

ScheduledActionService.Remove("MyReminder"); 

reminder.Title = "Updated Title"; 

ScheduledActionService.Add(reminder); 
+0

我試過你的方法。它不會工作。它刪除提醒,並不會添加或替換它,當我查詢與提醒= ScheduledActionService.GetActions ()顯示所有提醒。 – MilkBottle

0

根據ScheduledActionService.GetActions Method documentation page備註部分:

所調度的動作服務不保持通過該方法返回的 對象的引用,因此不更新 對象的屬性以反映當前狀態,調用 GetActions。要獲取系統更新爲 狀態更改的對象,請改爲使用查找(字符串)。

所以,只需使用Find(String)來代替。

+0

哦,該死的,我沒有看到問題的日期......我猜這個問題很久以前就已經解決了,對不起打擾... –