2013-05-13 42 views
0

我有一个媒体应用程序需要在活动图块上显示曲目图片和标题。现在我有以下代码: -活动图块更新

private void SetLiveTile() 
    { 
     var LiveTile = @"<tile> 
          <visual version=""1""> 
           <binding template=""TileWideSmallImageAndText01""> 
           <text id=""1"">" + MediaControl.ArtistName + " - " + MediaControl.TrackName + @"</text> 
           <image id=""1"" src=" + MediaControl.AlbumArt + @"""/> 
           </binding> 
           <binding template=""TileSquarePeekImageAndText02""> 
           <text id=""1"">" + MediaControl.ArtistName + " - " + MediaControl.TrackName + @"</text> 
           <image id=""1"" src=" + MediaControl.AlbumArt + @"""/> 
           </binding> 
          </visual> 
          </tile>"; 

     XmlDocument tileXml = new XmlDocument(); 
     tileXml.LoadXml(LiveTile); 

     var tileNotification = new Windows.UI.Notifications.TileNotification(tileXml); 
     Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification); 
    } 

它目前不工作,LoadXml失败,错误代码为c00ce502。

我也需要它至少每1分钟更新一次,但如果我可以每30秒更新一次,它会非常棒。它还需要删除活动拼贴,并在应用程序关闭时恢复为原始拼贴。

回答

1

对于它看起来像你错过了在src标签开引号的XML问题,请尝试

<image id=""1"" src=""" + MediaControl.AlbumArt + @"""/> 

至于更新一分钟或30秒的基础上,来看看this sample on dev.windows.com

因为没有以编程方式通知应用程序确实终止的所有情况,所以在终止时清除瓦片可能会非常棘手。