2013-07-28 24 views
0

Windows 8应用程序 - 地铁应用程序 - 嗨我想从网站更新平铺图像,但我无法让它工作。我使用这个Link 我只做了一些小的定制,但来自网络的图像没有为我工作。如果我使用const string src1 =“ms-appx:///Assets/clock24x24.png”;我在字符串src1中有图像。然后图像工作,但从网络它不工作。有没有人有一些想法?从网页源更新平铺图像 - Windows 8应用程序

public static void CreateSchedule() 
    { 


     var tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication(); 
     var plannedUpdated = tileUpdater.GetScheduledTileNotifications(); 
     DateTime now = DateTime.Now; 
     DateTime planTill = now.AddHours(4); 

     const string src1 = "http://cdn.thenextweb.com/wp-content/blogs.dir/1/files/2012/02/Screen-Shot-2012-02-21-at-4.48.56-PM.png"; 

     DateTime updateTime = new DateTime(now.Year, now.Month, now.Day, now.Hour, now.Minute, 0).AddMinutes(1); 
     if (plannedUpdated.Count > 0) 
      updateTime = plannedUpdated.Select(x => x.DeliveryTime.DateTime).Union(new [] { updateTime }).Max(); 
     string xml = "<tile>" 
         + "<visual>" 
         + "<binding template='TileWideImageAndText01'>" 
         + "<text id='1'>This tile notification uses web images</text>" 
         + "<image id='1' src='" + src1 + "' alt='Web image'/>" 
         + "</binding>" 
         + "<binding template='TileSquareImage'>" 
         + "<image id='1' src='" + src1 + "' alt='Web image'/>" 
         + "</binding>" 
         + "</visual>" 
         + "</tile>"; 
     var tileXmlNow = string.Format(xml); 
     XmlDocument documentNow = new XmlDocument(); 
     documentNow.LoadXml(tileXmlNow); 

     tileUpdater.Update(new TileNotification(documentNow) { ExpirationTime = now.AddMinutes(1) }); 

     for (var startPlanning = updateTime; startPlanning < planTill; startPlanning = startPlanning.AddMinutes(1)) 
     { 
      Debug.WriteLine(startPlanning); 
      Debug.WriteLine(planTill); 

      try 
      { 
       var tileXml = string.Format(xml); 
       XmlDocument document = new XmlDocument(); 
       document.LoadXml(tileXml); 

       ScheduledTileNotification scheduledNotification = new ScheduledTileNotification(document, new DateTimeOffset(startPlanning)) { ExpirationTime = startPlanning.AddMinutes(1) }; 
       tileUpdater.AddToSchedule(scheduledNotification); 

      } 
      catch (Exception e) 
      { 
      } 
     } 
    } 

回答

0

您是否已在包AppxManifest文件中激活了Internet功能?

+0

是的,权限还行 –