动态磁贴样式1
public static void SetupTileAlert(string f,string s,string b)
{
// In a real app, these would be initialized with actual data
string from = f;
string subject = s;
string body = b;
// TODO - all values need to be XML escaped
// Construct the tile content as a string
string content = $@"
<tile>
<visual>
<binding template='TileMedium'>
<text>{from}</text>
<text hint-style='captionSubtle'>{subject}</text>
<text hint-style='captionSubtle'>{body}</text>
</binding>
<binding template='TileWide'>
<text hint-style='subtitle'>{from}</text>
<text hint-style='captionSubtle'>{subject}</text>
<text hint-style='captionSubtle'>{body}</text>
</binding>
</visual>
</tile>";
// Load the string into an XmlDocument
XmlDocument doc = new XmlDocument();
doc.LoadXml(content);
// Then create the tile notification
var notification = new TileNotification(doc);
notification.ExpirationTime = DateTimeOffset.UtcNow.AddMinutes(10);
TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
if (SecondaryTile.Exists("MySecondaryTile"))
{
// Get its updater
var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile("MySecondaryTile");
// And send the notification
updater.Update(notification);
}
}
动态磁贴样式2
public async void SetupTileAlert2()
{
string imgurl = "ms-appx:///images/bg2.jpg";
string title ="提醒";
string description ="接下来需要参加";
string content = $@"
<tile branding='name'>
<visual version='3'>
<binding template='TileMedium'>
<image src='{imgurl}' placement='peek'/>
<text>{title}</text>
<text hint-style='captionsubtle' hint-wrap='true'>{description}</text>
</binding>
<binding template='TileWide'>
<image src='{imgurl}' placement='peek'/>
<text>{title}</text>
<text hint-style='captionsubtle' hint-wrap='true'>{description}</text>
</binding>
<binding template='TileLarge'>
<image src='{imgurl}' placement='peek'/>
<text>{title}</text>
<text hint-style='captionsubtle' hint-wrap='true'>{description}</text>
</binding>
</visual>
</tile>";
// Load the string into an XmlDocument
XmlDocument doc = new XmlDocument();
doc.LoadXml(content);
// Then create the tile notification
var notification = new TileNotification(doc);
notification.ExpirationTime = DateTimeOffset.UtcNow.AddMinutes(10);
TileUpdateManager.CreateTileUpdaterForApplication().Update(notification);
if (SecondaryTile.Exists("MySecondaryTile"))
{
// Get its updater
var updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile("MySecondaryTile");
// And send the notification
updater.Update(notification);
}
}
(the end)