How to create Microsoft Band Custom Icons within Pages - Windows UWP

Viewed 877

I've been trying to add a custom icon into a Filled Panel.

In the documentation there is some information on this in section 8.5 and the examples in the SDK's demonstrate that a developer can customise the Large and small icon of the tile. However there is no clear example of how to do this for a custom icon within the tile on a page.

Searching further, I found that there was a new Microsoft Band Tile Design Plugin for Visual Studio. This seems to demostrate what I wanted to do however when trying to use the code specified in the Code Generation section (Half way down the page), I failed to load a simple custom layout that I had created using the designer:

enter image description here

Here is the code that is linking the custom layout as described on the Tile Design Plugin Page:

try
            {
                // create a new Guid for the tile
                tileGuid = Guid.NewGuid();
                // create a new tile with a new Guid
                WriteableBitmap smallIconBitmap = new WriteableBitmap(24, 24);
                BandIcon smallIcon = smallIconBitmap.ToBandIcon();
                WriteableBitmap tileIconBitmap = new WriteableBitmap(48, 48);
                BandIcon tileIcon = tileIconBitmap.ToBandIcon();
                BandTile tile = new BandTile(tileGuid)
                {
                    // Name of the Tile
                    Name = "MyTile",
                    // Create the small and tile icons from writable bitmaps.
                    // Small icons are 24x24 pixels.
                    SmallIcon = smallIcon,
                    // Tile icons are 46x46 pixels for Microsoft Band 1, and 48x48 pixels
                    // for Microsoft Band 2.
                    TileIcon = tileIcon
                };
                var customtiledesign = new SentimentFeedbackLayout();
                tile.PageLayouts.Add(customtiledesign.Layout);
                await customtiledesign.LoadIconsAsync(tile);

                if (await bandClient.TileManager.AddTileAsync(tile))
                {
                    Debug.WriteLine("New tile added | GUID: " + tileGuid);
                }

                PageData pd = new PageData(tileGuid, 1, customtiledesign.Data.All);

                if (await bandClient.TileManager.SetPagesAsync(tileGuid, pd))
                {
                    Debug.WriteLine("Added pages");
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }

The error log is as follows:

Band Connected : MSFT Band 2 bb:bc
Version: 2.0.4215.0, Hardware: 26
Band - Removing all Tiles
Removed tile: MyTile
New tile added | GUID: 4803e0fe-2da2-4efb-9389-bde3a9289d30
Exception thrown: 'Microsoft.Band.BandOperationException' in mscorlib.ni.dll
Error Device status code: 0xA0CC006A received.

I couldn't find any details of the error online but I think its because I've used:

 PageData pd = new PageData(tileGuid, 1, customtiledesign.Data.All);

Instead of passing the customtiledesign.Data.All into the ...SetPagesAsync() method.

This was because there was no overloaded form of SetPageAsync that took PageElementData[] as an argument.

2 Answers
Related