如何将AdditionalIcons添加到Band中的tile

时间:2016-04-11 14:18:57

标签: microsoft-band

我正在开发Microsoft Band2应用程序,我想在一个乐队中添加额外的图标到我的应用程序磁贴,就像在Band2中设置磁贴一样。我按照以下代码将其他图标添加到磁贴

                    Guid pageguid = Guid.NewGuid();


                    var panel = new ScrollFlowPanel
                    {
                        Rect = new PageRect(0, 0, 260, 128),
                    };
                    panel.Elements.Add(new FlowPanel
                    {
                        Rect = new PageRect(0, 0, 32, 32),
                        HorizontalAlignment = Microsoft.Band.Tiles.Pages.HorizontalAlignment.Center,

                  });
                    panel.Elements.Add(new Icon
                    {
                        HorizontalAlignment = Microsoft.Band.Tiles.Pages.HorizontalAlignment.Center,
                        Rect= new PageRect(0, 0, 32, 32),
                        ColorSource= ElementColorSource.BandHighlight,
                    });


                    var layout = new PageLayout(panel);
                    BandTile tile = new BandTile(tileGuid)
                    {
                        Name = "EmergencyHelp ",
                        TileIcon = await LoadIcon("ms-appx:///Assets/User that is member of security group.png"),
                        SmallIcon = await LoadIcon("ms-appx:///Assets/User that is member of security groupSmall.png"),


                    };
                    int firstIconIndex = tile.AdditionalIcons.Count + 2; // First 2 are used by the Tile itself
                    tile.AdditionalIcons.Add(await LoadIconMethod(AdjustUriMethod("ms-appx:///Assets/User that is member of security groupSmall.png")));
                    pageLayoutData.ById<IconData>(3).IconIndex = (ushort)(firstIconIndex + 0);
                    tile.PageLayouts.Add(layout);
                    if (tile.TileId != null)
                    {
                        await client.TileManager.RemoveTileAsync(tile.TileId);
                    }

                    await client.TileManager.AddTileAsync(tile);
                    await client.TileManager.SetPagesAsync(
                   tileGuid,
                   new PageData(pageguid, 0, new TextButtonData(1, "Emergency")));

我得到了例外情况,如下图所示,

enter image description here

0 个答案:

没有答案