SecondaryTile class

3 out of 3 rated this helpful - Rate this topic

Creates, enumerates, and provides information about a secondary tile.

Syntax


var secondaryTile = new Windows.UI.StartScreen.SecondaryTile();
var secondaryTile = new Windows.UI.StartScreen.SecondaryTile(string);
var secondaryTile = new Windows.UI.StartScreen.SecondaryTile(string, string, string, string, tileOptions, uri);
var secondaryTile = new Windows.UI.StartScreen.SecondaryTile(string, string, string, string, tileOptions, uri, uri);

Attributes

ActivatableAttribute(NTDDI_WIN8)
ActivatableAttribute(Windows.UI.StartScreen.ISecondaryTileFactory, NTDDI_WIN8)
MuseAttribute()
StaticAttribute(Windows.UI.StartScreen.ISecondaryTileStatics, NTDDI_WIN8)
VersionAttribute(NTDDI_WIN8)

Members

The SecondaryTile class has these types of members:

Constructors

The SecondaryTile class has these constructors.

ConstructorDescription
SecondaryTile() Creates a SecondaryTile object. The caller must then set any required properties through the object before attempting to pin, update, or delete the tile.
SecondaryTile(String) Creates a SecondaryTile object with a specific ID. This form of the constructor should be used to create a secondary tile object to perform a tile update or deletion.
SecondaryTile(String, String, String, String, TileOptions, Uri) Creates a SecondaryTile object that includes all of the mandatory properties required to create a square tile.
SecondaryTile(String, String, String, String, TileOptions, Uri, Uri) Creates a SecondaryTile object that includes all of the mandatory properties required to create a wide tile.

 

Methods

The SecondaryTile class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

MethodDescription
Exists Checks whether a specific secondary tile exists for the calling app.
FindAllAsync() Retrieves a list of secondary tiles created for the calling app.
FindAllAsync(String) Retrieves a list of secondary tiles created for another app in the same package as the calling app.
FindAllForPackageAsync Retrieves a list of secondary tiles created for all of the apps in the package of the calling app.
RequestCreateAsync() Displays a preview of the secondary tile with a confirmation dialog to create the tile.
RequestCreateAsync(Point) Displays a preview of the secondary tile at the specified point, together with a confirmation dialog to create the tile.
RequestCreateForSelectionAsync(Rect) Displays a preview of the secondary tile above the specified rectangle, together with a confirmation dialog to create the tile.
RequestCreateForSelectionAsync(Rect, Placement) Displays a preview of the secondary tile at the given side of a specified rectangle, together with a confirmation dialog to create the tile.
RequestDeleteAsync() Displays a preview of the secondary tile with a confirmation dialog to delete the tile.
RequestDeleteAsync(Point) Displays a preview of the secondary tile at the specified point, together with a confirmation dialog to delete the tile.
RequestDeleteForSelectionAsync(Rect) Displays a preview of the secondary tile above the specified rectangle, together with a confirmation dialog to delete the tile.
RequestDeleteForSelectionAsync(Rect, Placement) Displays a preview of the secondary tile at the given side of a specified rectangle, together with a confirmation dialog to create the tile.
UpdateAsync Updates a secondary tile after that tile is pinned to the Start screen.

 

Properties

The SecondaryTile class has these properties.

PropertyAccess typeDescription

Arguments

Read/writeGets or sets an app-defined set of information that is passed from the secondary tile to the app on activation. This property is required when you create a tile.

BackgroundColor

Read/writeGets or sets the tile's background color.

DisplayName

Read/writeGets or sets a long name that is associated and displayed with the tile. Instances of where this name is used include the tile's tooltip, next to the small tile representation in the All Programs list, and some Control Panel applications. This property is required when you create a tile.

ForegroundText

Read/writeGets or sets whether the tile should use dark or light text.

LockScreenBadgeLogo

Read/writeGets or sets the location of a badge logo image to represent the secondary tile on the lock screen. By supplying this image, you declare that the secondary tile is eligible to display a badge on the lock screen.

LockScreenDisplayBadgeAndTileText

Read/writeGets or sets whether the secondary tile is eligible to display both a badge and a detailed tile on the lock screen.

Logo

Read/writeGets or sets the logo image used in a square tile. This property is required when you create either a square or a wide tile.

ShortName

Read/writeGets or sets a short name to display directly on the tile. This property is required when you create a tile.

SmallLogo

Read/writeGets or sets the small logo image, used in search results, the All Programs list, and other locations in the user interface (UI).

TileId

Read/writeGets or sets a unique string to identify the tile within the package. This property is required when you create or delete a tile.

TileOptions

Read/writeGets or sets options available to a secondary tile.

WideLogo

Read/writeGets or sets the logo image used in a wide tile. This property is required when you create a wide tile.

 

Examples

The following example creates and pins a secondary tile to the Start screen.



// Prepare package images for use as the Tile Logo and Small Logo in our tile to be pinned.
var uriLogo = new Windows.Foundation.Uri("ms-appx:///images/SecondaryTileDefault-sdk.png");
var uriSmallLogo = new Windows.Foundation.Uri("ms-appx:///images/smallLogoSecondaryTile-sdk.png");

// Create a tile to be be pinned.

// During creation of secondary tiles, an application can set additional arguments on the tile 
// that will be passed in during activation. These arguments should be meaningful to the application. 
// In this example, we'll pass in the date and time that the Secondary Tile was pinned.
var currentTime = new Date();
var tileActivationArguments = "timeTileWasPinned=" + currentTime;

// Specify the short name to display on the tile, the display name, arguments to be passed in 
// during activation, attributes regarding how to display the tile by default, and the tile logo.
// Note that you should pick a unique ID that is descriptive and meaningful to your application. 
// In this case, we explicitly code a single ID to focus our attention on the pinning operation.

var tile = new Windows.UI.StartScreen.SecondaryTile("SecondaryTile.01", 
                                                    "A Secondary Tile", 
                                                    "Secondary Tile Sample Secondary Tile", 
                                                    tileActivationArguments, 
                                                    Windows.UI.StartScreen.TileOptions.showNameOnLogo, 
                                                    uriLogo);

// Specify a foreground text value.
// The secondary tile background color over which this text is shown is inherited from the 
// parent app unless a separate value is specified.
tile.foregroundText = Windows.UI.StartScreen.ForegroundText.dark;

// The small tile logo is inherited from the parent app unless overridden as we do here.
tile.smallLogo = uriSmallLogo;

// Attempt to pin the tile.
// Note that the status message is updated when the async operation to pin the tile completes.

tile.requestCreateAsync().then(function (isCreated) {
    if (isCreated) {
        // Secondary tile successfully pinned.
    } else {
        // Secondary tile not pinned.
    }
});

The following example demonstrates how to delete (unpin) a secondary tile by using the RequestDeleteAsync method. Note that this example assumes that the tile exists. To determine whether the tile is pinned before you call RequestDeleteAsync, see the Exists method.



// Specify the secondary tile to be deleted, using the ID that it was given when it was originally created.
var tileToBeDeleted = new Windows.UI.StartScreen.SecondaryTile("SecondaryTile.01");

// Make the delete request.
tileToBeDeleted.requestDeleteAsync().then(function (isDeleted) {
    if (isDeleted) {
        // Secondary tile successfully deleted.
    } else {
        // Secondary tile not deleted.
    }
});

The following example demonstrates how to use the FindAllForPackageAsync method to retrieve a list of IDs for all secondary tiles created for the calling app and any other app in the same package.



Windows.UI.StartScreen.SecondaryTile.findAllForPackageAsync().done(function (tiles) {
    tiles.forEach(function (tile) {
        var myTileId = tile.tileId;
        // Continue to process as necessary.
    });
});

The following example demonstrates how to use the TileUpdateManager.createTileUpdaterForSecondaryTile method to send a notification to a secondary tile with an ID of "SecondaryTile.Dynamic". Note that the example provides both a wide and square version of the notification because the user has control over which form of the tile is showing.



var notifications = Windows.UI.Notifications;

// Define the notification content.
var tileXml = notifications.TileUpdateManager.getTemplateContent(notifications.TileTemplateType.tileWideText04);
var tileTextAttributes = tileXml.getElementsByTagName("text");
tileTextAttributes[0].appendChild(tileXml.createTextNode("Sent to a secondary tile!"));

// Provide a square version of the notification.
var squareTileXml = notifications.TileUpdateManager.getTemplateContent(notifications.TileTemplateType.tileSquareText04);
var squareTileTextAttributes = squareTileXml.getElementsByTagName("text");
squareTileTextAttributes[0].appendChild(squareTileXml.createTextNode("Sent to a secondary tile!"));

// Add the square tile to the notification.
var node = tileXml.importNode(squareTileXml.getElementsByTagName("binding").item(0), true);
tileXml.getElementsByTagName("visual").item(0).appendChild(node);

// Create the notification based on the XML content.
var tileNotification = new notifications.TileNotification(tileXml);

// Create a secondary tile updater, passing it the ID of the tile.
var tileUpdater = notifications.TileUpdateManager.createTileUpdaterForSecondaryTile("SecondaryTile.Dynamic");

// Send the notification to the secondary tile.
tileUpdater.update(tileNotification);

The following example demonstrates how to use the BadgeUpdateManager.createBadgeUpdaterForSecondaryTile method to send a numeric badge notification to a secondary tile with an ID of "SecondaryTile.Dynamic".



var notifications = Windows.UI.Notifications;

// Define the badge content
var badgeNotification = notifications.BadgeUpdateManager.getTemplateContent(notifications.BadgeTemplateType.badgeNumber);
var badgeAttributes = badgeNotification.getElementsByTagName("badge");
badgeAttributes[0].setAttribute("value", "6");

// Create the notification based on the XML content.
var badge = new notifications.BadgeNotification(badgeNotification);

// Create a secondary tile updater, passing it the ID of the tile.
notifications.BadgeUpdateManager.createBadgeUpdaterForSecondaryTile("SecondaryTile.Dynamic");

// Send the notification to the secondary tile.
tileUpdater.update(tileNotification);

Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Namespace

Windows.UI.StartScreen
Windows::UI::StartScreen [C++]

Metadata

Windows.winmd

See also

Secondary tiles sample

 

 

Build date: 12/4/2012

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.