WinRTLiveTileManager
- 4 minutes to read
Important
The WinRTLiveTileManager component is compatible only with Windows 8 and Windows 8.1
Online Video
Concepts
The WinRTLiveTileManager component allows you to create Windows Forms applications that are fully compatible with the Microsoft Windows 8 OS. Use this component in your Windows Forms application to create Live Tile(s) for this app within the Windows 8 Start Screen.
The WinRTLiveTileManager component requires a separate DevExpress Live Tile Manager Windows Store application to be installed on machines of end-users. You can also install it on your machine for debug purposes. The DevExpress Live Tile Manager app can be easily found in the Microsoft Windows Store. This application serves as a bridge between the WinRTLiveTileManager WinForms component and the Windows 8 Start Screen. For end-users, this app provides a UI allowing them to pin and unpin Live Tiles created via the WinRTLiveTileManager component to/from the Windows 8 Start Screen:
A Live Tile consists of the following visual elements:
- Tile Content - may include multiple text lines and/or images depending on a selected tile template. WinRTLiveTileManager supports all templates listed in the Microsoft Tile Template Catalog article.
- Application Name - the application name, displayed within a Live Tile. Specified via the WinRTLiveTileManager.ApplicationName property.
- Badge - an optional element that can display either an integer value, or one of the included signs (error, exclamation, notification etc). Use the WinRTLiveTileManager.UpdateBadge method to specify a Tile Badge.
- Background Image - the default Live Tile Image, specified via the WinRTLiveTileManager.DefaultTileImage property. This image is replaced whenever you call the WinRTLiveTileManager.UpdateTile method to apply a new Tile Template.
Getting Started
To use the WinRTLiveTileManager control, open your existing Windows Forms project, locate the WinRTLiveTileManager component in the Visual Studio toolbox and drop it onto the application form.
Assign the ContainerControl object that hosts the WinForms app (app module) to the WinRTLiveTileManager.ContainerControl property, to assosiate this app (module) with the WinRTLiveTileManager component. You can also specify the WinRTLiveTileManager.ApplicationName property to set the application name displayed within a corresponding Live Tile.
If you launch the application, and then switch to the DevExpress Live Tile Manager Windows Store app, you will see a Tile. This Tile can be pinned to the Windows 8 Start Screen, but it is static and not actually a ‘Live’ Tile yet. Live Tiles display real-time notifications related to the current application state when the application is running but not focused. To display these notifications, use the WinRTLiveTileManager.UpdateTile method. This method takes the WideTile and SquareTile objects as parameters. These objects contain Tile Templates for large and regular size Tiles respectively. The following code illustrates an example:
WideTile myWideTile = WideTile.CreateTileWideText03("Sample Tile");
SquareTile mySquareTile = SquareTile.CreateTileSquareBlock("14", "April");
winRTLiveTileManager1.UpdateTile(myWideTile, mySquareTile);
Note
All methods that create tiles are named after the corresponding tile templates mentioned above. You can refer to the Tile Template Catalog article, and use the corresponding methods to create a Tile of the desired type.
The image below illustrates an example of both Wide and Square Tile Templates, created via code above.
If you use a WideTile template for your Live Tile, you can pass null to the WinRTLiveTileManager.UpdateTile method instead of a SquareTile. But it’s strongly recommended to pass both a WideTile and SquareTile objects when updating a Live Tile, because an end-user can manually resize a Tile by standard Windows 8 means (to do so, right-click a Live Tile to select it and clich the ‘Larger’ or ‘Smaller’ option from the Apps bar below).
You can optionally update a Live Tile’s Badge when updating its content. The following code sets a ‘New Message’ badge for a Tile:
If your application has multiple modules, each of them containing a WinRTLiveTileManager component, and multiple Live Tiles are pinned to the Windows 8 Start Screen, you can get the Tile that an end-user clicked. To do so, call the WinRTLiveTileManager.InitializeNavigation method and handle the WinRTLiveTileManager.OnNavigated event, as shown below.
public Form1() {
InitializeComponent();
WinRTLiveTileManager.InitializeNavigation();
WinRTLiveTileManager.OnNavigated += WinRTLiveTileManager_OnNavigated;
. . .
}
void WinRTLiveTileManager_OnNavigated(string obj) {
//do something
}
The obj parameter returns the related WinRTLiveTileManager ID (the WinRTLiveTileManager.Id property), so you can check the ID and get the Live Tile that was clicked. The ID for each WinRTLiveTileManager is generated automatically and cannot be modified.