WindowsPhone 7.8 Tiles 1 - WideTile

发布时间:2025-12-10 11:38:18 浏览次数:5

7.8 SDK 终于出了(下载:http://www.cnblogs.com/sun8134/archive/2013/01/23/2872562.html)

可惜一个api都木有…

唯一增加的就是tile的变化

详细见MSDN文档:http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj720574(v=vs.105).aspx

Supported features


 

A Windows Phone OS 7.1 app that runs on Windows Phone 8 or Windows Phone 7.8 supports the following Tile features:

  • For the default Tile, the flip Tile is the only supported template. For more information about this template, see Flip Tile template for Windows Phone 8.

  • For secondary Tiles, all Tile templates are supported: Flip Tile template for Windows Phone 8, Iconic Tile template for Windows Phone 8, and Cycle Tile template for Windows Phone 8.

  • Independently update the small and medium Tile sizes. You can also optionally support the wide Tile size.

  • You can use both push notifications and the ShellTile APIs to update Tiles.


默认的Tile只支持Flip Tile 我们来看看实现的效果吧:

 

首先要看下Flip Tile的结构,还是看MSDN文档吧:http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206971(v=vs.105).aspx

 

下面准备需要的图片,大小分别为159*159,336*336,691*336

还有一张对应wp7.5的173*173

 

然后开始code,第一步摇先判断版本,是否为7.8

//设定版本 private static Version TargetedVersion = new Version(7, 10, 8858);   //判断是否满足版本要求 public static bool isTargetedVersion { get { return Environment.OSVersion.Version >= TargetedVersion; } }

 

如果大约等于7.8,则替换默认tile为Flip Tile:

ShellTile appTile = ShellTile.ActiveTiles.First(); // Get the new FlipTileData type. Type flipTileDataType = Type.GetType("Microsoft.Phone.Shell.FlipTileData, Microsoft.Phone");   // Get the ShellTile type so we can call the new version of "Update" that takes the new Tile templates. Type shellTileType = Type.GetType("Microsoft.Phone.Shell.ShellTile, Microsoft.Phone");   // Loop through any existing Tiles that are pinned to Start. //var tileToUpdate = ShellTile.ActiveTiles.First();     // Get the constructor for the new FlipTileData class and assign it to our variable to hold the Tile properties. var UpdateTileData = flipTileDataType.GetConstructor(new Type[] { }).Invoke(null);   // Set the properties. SetProperty(UpdateTileData, "Title", "Main Tile Title"); SetProperty(UpdateTileData, "Count", 0); SetProperty(UpdateTileData, "BackTitle", "Back Tile Title"); SetProperty(UpdateTileData, "BackContent", "Content For back tile."); SetProperty(UpdateTileData, "SmallBackgroundImage", new Uri("Windows 8 59.png", UriKind.Relative)); SetProperty(UpdateTileData, "BackgroundImage", new Uri("Windows 8 336.png", UriKind.Relative)); SetProperty(UpdateTileData, "BackBackgroundImage", new Uri("", UriKind.Relative)); SetProperty(UpdateTileData, "WideBackgroundImage", new Uri("Windows 8 691.png", UriKind.Relative)); SetProperty(UpdateTileData, "WideBackBackgroundImage", new Uri("", UriKind.Relative)); SetProperty(UpdateTileData, "WideBackContent", "Content for Wide Back Tile. Lots more text here.");   // Invoke the new version of ShellTile.Update. shellTileType.GetMethod("Update").Invoke(appTile, new Object[] { UpdateTileData });

设定Flip Tile属性的方法:

private static void SetProperty(object instance, string name, object value) { var setMethod = instance.GetType().GetProperty(name).GetSetMethod(); setMethod.Invoke(instance, new object[] { value }); }

另外在英文的MSDN文档(http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj720574(v=vs.105).aspx)里要求修改WMAppManifest.xml,添加AppExtra节点:

而且说明添加后在vs2010里会编译报错,只有VS2012才能顺利通过,如果在vs2010中使用的话需要先编译生成xap,然后解压出WMAppManifest.xml,修改后再重新打包进去…

但是这段说明在中文版的MSDN文档(http://msdn.microsoft.com/zh-cn/library/windowsphone/develop/jj720574(v=vs.105).aspx)里被删除了

而且我在vs2010中测试那段代码加和不加没什么区别…难道是beta版的时候的要求么?

 

最后看看效果:

 

源码:

 

 

参考:

http://msdn.microsoft.com/zh-cn/library/windowsphone/develop/jj720574(v=vs.105).aspx

http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj720574(v=vs.105).aspx

http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj206971(v=vs.105).aspx

http://blogs.msdn.com/b/lmoroney/archive/2013/01/28/create-a-windows-phone-7-flip-tile-and-update-it-to-windows-phone-8-style-using-the-windows-phone-7-8-sdk.aspx

转载于:https://www.cnblogs.com/sun8134/archive/2013/02/04/2892421.html

需要做网站?需要网络推广?欢迎咨询客户经理 13272073477