SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Windows Phone Application Development Tutorials, Articles and Resources for Mobile App Programmers


How to Create Flip Tile Programmatically in Windows Phone 8 App

App programmers can find sample code to create flip tile for Windows Phone 8 app pages by using code programmatically in this Windows Phone app development tutorial. Windows Phone 8 flip tiles has two faces and flips periodically showing the other surface with each flip. App developers can configure background images and displayed content on each tile surface. This tutorial provides sample C-Sharp code showing how to create flip tile programmatically just like creating a cycle tile.

Windows Phone app developers can use below C-Sharp code sample to create flip tile for their app pages programmatically. To create flip tile for your Windows Phone 8 app, app developer should create an instance of FlipTileData class and populate FlipTileData class properties like Title, BackTitle, BackContent, BackgroundImage, BackBackgroundImage, etc. After all properties of the secondary flip tile is populated for FlipTileData class instance, ShellTile.Create() method is used to create a new tile for the Windows Phone 8 app.

Following C# code is from my recent Windows Phone 8 app Evil Eye Beads app (Nazar Boncugu). When the user chooses an image, the below code executes within the Windows Phone 8 app to create secondary flip tile for the app on Start screen.

ShellTile tile = ShellTile.ActiveTiles.FirstOrDefault(o => o.NavigationUri.ToString().Contains("/MainPage.xaml"));

List<Uri> imageList = new List<Uri>();
Uri uri = new Uri(imageURL, UriKind.Relative);
imageList.Add(uri);

FlipTileData fliptile = new FlipTileData();

fliptile.Title = "";
fliptile.BackTitle = "";
fliptile.BackContent = "";
fliptile.Count = null;
fliptile.BackBackgroundImage = imageList[0];
fliptile.BackgroundImage = imageList[0];

ShellTile.Create(new Uri("/MainPage.xaml", UriKind.Relative), fliptile, false);
Code

Please note that the above sample code uses the same image as background image of the front view of the flip tile as well as the back background of it. The developer can use different images for the tile BackgroundImage and tile BackBackgroundImage.

Within the sample app code, the user can choose an other item to be displayed as a flip tile on his or her smartphone start screen. This requires an update of the flip tile which is active for the app.

Of course if there is already a flip tile created previously, instead of creating a new tile for the same URI to prevent an exception, app developer should update existing app tile. Here is sample app codes that programmers can use to update flip tile using FlipTileData class and ShellTile.Update() method.

ShellTile tile = ShellTile.ActiveTiles.FirstOrDefault(o => o.NavigationUri.ToString().Contains("/MainPage.xaml"));

List<Uri> imageList = new List<Uri>();
Uri uri = new Uri(imageURL, UriKind.Relative);
imageList.Add(uri);

FlipTileData fliptile = new FlipTileData();

fliptile.Title = "";
fliptile.BackTitle = "";
fliptile.BackContent = "";
fliptile.Count = null;
fliptile.BackBackgroundImage = imageList[0];
fliptile.BackgroundImage = imageList[0];

tile.Update(fliptile);
Code

As you already know, Windows Phone 8 app development enhancements enable an app developer to use 3 different types of tiles for his or her app. These tile types are iconic tile, flip tile and cycle tile. During tile update, if the existing tile type and new tile type are not compatible, then ShellTile.Update() method will throw exception. To prevent such an error, the app developer can first remove existing tile by executing ShellTile.Delete() method, then create new tile with ShellTile.Create()



Windows 10 Games

Microsoft Games on Windows 8 and Windows 10


Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.