0
當我嘗試更新我的UWP主要和/或輔助磁貼時,什麼都不會發生。UWP Live Tile沒有更新
如果我從Visual Studio 2017開始我的UWP應用程序更新功能正常工作,並更新瓷磚。 但是,如果我從VS 2017製作Windows應用商店應用,則更新功能不再起作用。
這是我當前的更新功能:
using System;
using System.Diagnostics;
using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;
using Windows.UI.Xaml.Controls;
namespace UpdateTile
{
public sealed class TileUpdate
{
// Function which is call by every background task to update the app tile
// and each app secondary tile
// The tile ID could be empty for update the primary tile
public static void ScheduleUpdate(String data, String tileID)
{
#region variables
TileUpdater tileUpdater = null;
#endregion
// Check the tile ID
if (tileID == "")
{
// If tile ID is empty then create a tile updater for the app tile
tileUpdater = TileUpdateManager.CreateTileUpdaterForApplication();
}
else
{
tileUpdater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(tileID);
}
tileUpdater.EnableNotificationQueue(true);
tileUpdater.Clear();
tileUpdater.Update(new TileNotification(new TileXML().WriteXml(data)));
}
}
}
}
這是怎麼了我實際上是瓷磚創建XML:
using System;
using System.Diagnostics;
using SystemInformation;
using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;
using Microsoft.Toolkit.Uwp.Notifications;
namespace UpdateTile
{
public sealed class TileXML
{
// Function to create a xml document for tiles
// returns a xml document
public XmlDocument WriteXml(String data)
{
#region variables
String[] result = { "" }; ;
SystemInfo sysinfo = new SystemInfo();
TileContent content = null;
String textCaption = "";
String textCaptionSubTle1 = "";
String textCaptionSubTle2 = "";
String textCaptionSubTle3 = "";
#endregion
Debug.WriteLine("Create xml document for tile");
if (String.IsNullOrEmpty(data))
{
// Set xml text for initial text file data
textCaption = "No data available";
}
else
{
// Split text file data by carriage return and new line
result = data.Split(new string[] { "\n", "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
// check the result length to create an xml document text
if (result.Length == 1)
{
// Set xml text if no data file exists
textCaption = "No data available";
}
else
{
// Set xml text if data file is present
textCaption = sysinfo.Hostname;
textCaptionSubTle1 = result[3].Replace("Enterprise", "") + " v" + result[4];
textCaptionSubTle2 = "IP: " + sysinfo.IP_Address;
textCaptionSubTle3 = "Hotline: " + result[1];
}
}
// Create an adaptive tile content
content = new TileContent()
{
Visual = new TileVisual()
{
TileWide = new TileBinding()
{
Content = new TileBindingContentAdaptive()
{
BackgroundImage = new TileBackgroundImage()
{
Source = "Assets/Backgroung.png",
HintOverlay = 60
},
Children =
{
new AdaptiveText()
{
Text = textCaption,
HintStyle = AdaptiveTextStyle.Caption
},
new AdaptiveText()
{
Text = textCaptionSubTle1,
HintStyle = AdaptiveTextStyle.CaptionSubtle
},
new AdaptiveText()
{
Text = textCaptionSubTle2,
HintStyle = AdaptiveTextStyle.CaptionSubtle
},
new AdaptiveText()
{
Text = textCaptionSubTle3,
HintStyle = AdaptiveTextStyle.CaptionSubtle
}
}
}
}
}
};
// return the xml domument from adaptive tile content
return content.GetXml();
}
}
}
我也曾嘗試使用RAW XML來更新瓷磚,但沒有任何工作。有沒有人有一個想法,爲什麼瓦片更新適用於VS 2017,但不是作爲Windows應用商店的應用程序?
發行者證書已作爲根證書導入。
我的系統信息: 操作系統:Windows 10 v1703 - >版本:10.0.15063.540