• 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:


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

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

    image

    image

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

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

    image

    然后开始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节点:

    image

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

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

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

    最后看看效果:

    imageimage

    源码:

    参考:

    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

  • 相关阅读:
    part17 一些知识总结
    part16 php面向对象
    part15 php函数
    part14 php foreach循环
    part13 数组排序
    part12 php数组
    part11 php条件语句
    part10 php运算符
    part09 php字符串变量
    part08 php常量
  • 原文地址:https://www.cnblogs.com/sun8134/p/2892421.html
Copyright © 2020-2023  润新知