I am facing a problem with Live Tiles in my UWP application. Microsoft provides different templates (MSDN) for different tile sizes to set the content but it also depends on the device how the content is displayed.
For example the wide tile can show more characters on a mobile device than on a desktop computer in a single row, but I want to use the most of the tile area for information display. Let's say the user has installed my app on a desktop computer and he has pinned the big square tile to his start menu. How can I detect the tile size to load the appropriate template? Basically I just want to use a different template depending on the tile the user has pinned (and then I want to handle the filling of the content depending on the used device, but I got that already covered).
Currently I am just using a wide template that does nothing if the user has pinned any other size than the wide one. If the user pinns the wide tile, it works. But I am struggling to find a generic solution for this issue. I'm using SheduledTileNotifications because my app only uses local data for the tile contents.
This is my code to update a tile with a given template:
public static void UpdatePrimaryTile(XmlDocument tileTemplate)
{
var dt = DateTime.Now.AddSeconds(5);
dt = DateTime.SpecifyKind(dt, DateTimeKind.Unspecified);
var not = new ScheduledTileNotification(tileTemplate, new DateTimeOffset(dt, TimeZoneInfo.Local.BaseUtcOffset));
var tu = TileUpdateManager.CreateTileUpdaterForApplication();
tu.EnableNotificationQueue(true);
tu.Clear();
tu.AddToSchedule(not);
}