我一直在尝试将自定义图标添加到填充面板中。
在文档的第8.5节中提供了一些相关信息,SDK示例演示了开发人员如何自定义磁贴的大、小图标。但是,在页面上自定义图标的操作没有清晰的示例。
进一步搜索后,我发现有一个新的Microsoft Band Tile Design Plugin适用于Visual Studio。这似乎展示了我想要实现的功能,但是当我尝试使用代码生成部分(页面中间)指定的代码时,我无法加载使用设计师创建的简单自定义布局:
以下是将自定义布局链接为瓷砖设计插件页面上所述的代码:
错误日志如下:
这里是将自定义布局链接为瓷砖设计插件页面上所述的代码:
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);
}
错误日志如下:
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.
我在网上找不到关于这个错误的详细信息,但我认为这是因为我使用了:
PageData pd = new PageData(tileGuid, 1, customtiledesign.Data.All);
与其将customtiledesign.Data.All传递到...SetPagesAsync()方法中,不如采用其他方式。
这是因为没有重载的SetPageAsync形式接受PageElementData[]作为参数。