WindowsPhone 7.8 Tiles 1 : WideTile
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
總結
以上是生活随笔為你收集整理的WindowsPhone 7.8 Tiles 1 : WideTile的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 将EditText的光标定位到字符的最后
- 下一篇: PHP.ini修改配置下载上传文件大小