I said earlier that code can be shared between Universal Apps. This is true, but there are a few exceptions. For the most part, you can think of WinPRT as a subset of WinRT. There are several methods that WinRT has that will throw a NotImplementedException if you call them from WinPRT.
Mostly, these are thrown if you call methods that are not appropriate for using on a phone, such as trying to view the file system. However, there are some occasions where this can crop up when you’re doing something that might seem appropriate. The prime example of this is with Live Tiles.
Both Windows 8.1 and Windows 8 have live tiles, and in Universal Apps you create them in the same way. However, Windows 8.1 supports live tile sizes that Windows Phone 8.1 does not. There’s a full description of all of the live tiles available on MSDN at The tile template catalog (Windows Runtime apps).
Obviously, the solution to this is that you’ll want your code to skip generating those live tiles on the phone.
Luckily, we can do this fairly easily with compile-time constants. When your Universal App project is compiled for the Windows Phone app, a constant WINDOWS_PHONE_APP is created. We can just check for this in our code to skip over live tile generation, like this:
var tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text04); var tileTextAttributes = tileXml.GetElementsByTagName("text"); tileTextAttributes.InnerText = text; var squareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare150x150Text04); var squareTileTextAttributes = squareTileXml.GetElementsByTagName("text"); squareTileTextAttributes.AppendChild(squareTileXml.CreateTextNode(text)); var node = tileXml.ImportNode(squareTileXml.GetElementsByTagName("binding").Item(0), true); tileXml.GetElementsByTagName("visual").Item(0).AppendChild(node); #if !WINDOWS_PHONE_APP var bigSquareTileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquare310x310TextList02); var bigSquareTileTextAttributes = bigSquareTileXml.GetElementsByTagName("text"); bigSquareTileTextAttributes.AppendChild(bigSquareTileXml.CreateTextNode(text)); node = tileXml.ImportNode(bigSquareTileXml.GetElementsByTagName("binding").Item(0), true); tileXml.GetElementsByTagName("visual").Item(0).AppendChild(node); #endif var tileNotification = new TileNotification(tileXml); TileUpdateManager.CreateTileUpdaterForApplication().Update(tileNotification);