2012-09-06 66 views
0

我創建了4個圖塊模板內容,並在啓動應用程序時使用這四個模板更新圖塊。無法更新圖塊內容

現在我只想從應用程序中清除一個圖塊模板。我試過

TileUpdateManager.CreateTileUpdaterForApplication().Clear(); 

但這是清除所有的瓷磚模板。我如何清除一塊特定的瓷磚?

回答

0

這是不可能的Clear從瓦片的特定通知。 Clear方法刪除所有通知。

要使瓦片內容過期,請考慮在TileNotification類中使用ExpirationTime屬性,或者調用Clear,然後重新發送仍然有效的通知。

0

給這花了我一段時間來弄清楚,所以以爲我會發布我的代碼爲尋找一個快速的答案。

private void ClearScheduledTileNotifications() 
    { 
     var notify = Notifications.TileUpdateManager.CreateTileUpdaterForApplication(); 

    // Clear the notifications. This wil stop the live tile stuff straight out, but it wont remove the items from the list. 
     notify.Clear(); 

     // Get the list of notifications 
     var list = notify.GetScheduledTileNotifications(); 
     // Loop through the list of notifications and remove them from the manager. 
     foreach (var item in list) 
     { 
      // NOTE: If you want the list to exist, you could change the expiration date here as recommended in the 
    // MS Article above. I am just removing. You could also search for specific criteria here, or use linq on the query above. 
      Notifications.TileUpdateManager.CreateTileUpdaterForApplication().RemoveFromSchedule(item); 
     } 
    }