Nitish Bangad
Nitish Bangad

Reputation: 51

How to Include all 3 sizes of Tile in windows phone 7 app

I am developing a windows phone.Small and medium are already included. I want to add the wide size tile into that. How can I do that?

Upvotes: 1

Views: 151

Answers (2)

asitis
asitis

Reputation: 3031

The key difference between Windows Phone OS 7.1 and Windows Phone 8 Tiles is that Windows Phone OS 7.1 offers only one Tile template. This template is called TileTemplate5, and maps to the flip template in Windows Phone 8.TileTemplate5 is only available in one size, which maps to the medium size in Windows Phone 8.

Please check this link for more information

And i think you are going to add Wide tile in Windows Phone 8 application.Do the following ..
1.Open the WMManifest.xml file
2.Tick Support for Large Tiles
3.Choose the correct image for the Large[Wide] Tile.

Upvotes: 0

Chris Shao
Chris Shao

Reputation: 8231

You can include large tile in wp7.8 like this:

   public class CheckOSVersion
    {

        private static Version TargetedVersion;

        public static bool IsTargetedVersion
        {
            get { return Environment.OSVersion.Version >= CheckOSVersion.TargetedVersion; }
        }

        static CheckOSVersion() { CheckOSVersion.TargetedVersion = new Version(7, 10, 8858); }

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

        public static void UpdateFlipTile(string title, string backTitle, string backContent, string wideBackContent, int count, Uri tileId, Uri smallBackgroundImage, Uri backgroundImage, Uri backBackgroundImage, Uri wideBackgroundImage, Uri wideBackBackgroundImage)
        {
            try
            {
                if (CheckOSVersion.IsTargetedVersion)
                {
                    Type type = Type.GetType("Microsoft.Phone.Shell.FlipTileData, Microsoft.Phone");
                    Type type1 = Type.GetType("Microsoft.Phone.Shell.ShellTile, Microsoft.Phone");
                    foreach (ShellTile activeTile in ShellTile.ActiveTiles)
                    {
                        if (activeTile.NavigationUri.ToString() != tileId.ToString() && !activeTile.NavigationUri.ToString().Equals("/Login.xaml?flag=0"))
                        {
                            continue;
                        }
                        object obj = type.GetConstructor(new Type[0]).Invoke(null);
                        CheckOSVersion.SetProperty(obj, "Title", title);
                        CheckOSVersion.SetProperty(obj, "Count", count);
                        CheckOSVersion.SetProperty(obj, "BackTitle", backTitle);
                        CheckOSVersion.SetProperty(obj, "BackContent", backContent);
                        CheckOSVersion.SetProperty(obj, "SmallBackgroundImage", smallBackgroundImage);
                        CheckOSVersion.SetProperty(obj, "BackgroundImage", backgroundImage);
                        CheckOSVersion.SetProperty(obj, "BackBackgroundImage", backBackgroundImage);
                        CheckOSVersion.SetProperty(obj, "WideBackgroundImage", wideBackgroundImage);
                        CheckOSVersion.SetProperty(obj, "WideBackBackgroundImage", wideBackBackgroundImage);
                        CheckOSVersion.SetProperty(obj, "WideBackContent", wideBackContent);

                        object[] objArray = new object[1];
                        objArray[0] = obj;
                        type1.GetMethod("Update").Invoke(activeTile, objArray);
                        //break;
                    }
                }
            }
            catch { }
        }

        public static void CreateFlipTile(string title, string backTitle, string backContent, string wideBackContent, int count, Uri tileId, Uri smallBackgroundImage, Uri backgroundImage, Uri backBackgroundImage, Uri wideBackgroundImage, Uri wideBackBackgroundImage)
        {
            try
            {
                if (CheckOSVersion.IsTargetedVersion)
                {
                    Type type = Type.GetType("Microsoft.Phone.Shell.FlipTileData, Microsoft.Phone");
                    Type type1 = Type.GetType("Microsoft.Phone.Shell.ShellTile, Microsoft.Phone");
                    object obj = type.GetConstructor(new Type[0]).Invoke(null);
                    CheckOSVersion.SetProperty(obj, "Title", title);
                    CheckOSVersion.SetProperty(obj, "Count", count);
                    CheckOSVersion.SetProperty(obj, "BackTitle", backTitle);
                    CheckOSVersion.SetProperty(obj, "BackContent", backContent);
                    CheckOSVersion.SetProperty(obj, "SmallBackgroundImage", smallBackgroundImage);
                    CheckOSVersion.SetProperty(obj, "BackgroundImage", backgroundImage);
                    CheckOSVersion.SetProperty(obj, "BackBackgroundImage", backBackgroundImage);
                    CheckOSVersion.SetProperty(obj, "WideBackgroundImage", wideBackgroundImage);
                    CheckOSVersion.SetProperty(obj, "WideBackBackgroundImage", wideBackBackgroundImage);
                    CheckOSVersion.SetProperty(obj, "WideBackContent", wideBackContent);


                    object[] objArray = new object[1];
                    objArray[0] = obj;
                    MethodInfo createmethod = type1.GetMethod("Create", new[] { typeof(Uri), typeof(ShellTileData), typeof(bool) });
                    createmethod.Invoke(null, new object[] { tileId, obj, true });
                }
            }
            catch { }
        }
    }

Upvotes: 1

Related Questions