我正在编写一个 Windows 8 应用程序并试图让动态磁贴工作。这是我到目前为止所拥有的(全部在App.xaml.cs
):
在OnLaunched()
:
Window.Current.VisibilityChanged += Current_VisibilityChanged;
事件处理程序:
void Current_VisibilityChanged(object sender, Windows.UI.Core.VisibilityChangedEventArgs e)
{
// create a string with the tile template xml
string tileXmlString = "<tile><visual><binding template=\"TileSquareBlock\">" + App.VM.GetImageLinks() + "</binding></visual></tile>";
// create a DOM
Windows.Data.Xml.Dom.XmlDocument tileDOM = new Windows.Data.Xml.Dom.XmlDocument();
// load the xml string into the DOM, catching any invalid xml characters
tileDOM.LoadXml(tileXmlString);
// create a tile notification
TileNotification tile = new TileNotification(tileDOM);
// send the notification to the app's application tile
TileUpdateManager.CreateTileUpdaterForApplication().Update(tile);
}
App.VM.GetImageLinks()
返回:
<tile>
<visual>
<binding template=\"TileSquareBlock\">
<image id=\"1\">Assets/Img1.jpg</image>
<image id=\"2\">Assets/Img2.jpg</image>
<image id=\"3\">Assets/Img3.jpg</image>
</binding>
</visual>
</tile>
目前,我基本上只是想让这些图像显示在开始屏幕上。我的猜测是这VisibilityChanged
是错误的事件,因为它似乎发生得太频繁了。