自定义页面内容未显示在带区磁贴中时遇到问题
Having an issue with custom page content not showing in the band tile
我在 bandClient.TileManager.SetPagesAsync 返回 true 时遇到问题,我认为这意味着一切都成功了,但是当我单击我的 band 磁贴时,没有任何显示。我省略了下面的磁贴创建代码,因为我相信它工作正常,因为我能够成功地向它发送消息。有什么想法吗?
private void CreateLeaderboardPageLayout(BandTile tile)
{
// create a scrollable vertical panel that will hold 3 text messages
ScrollFlowPanel panel = new ScrollFlowPanel
{
Rect = new PageRect(0, 0, 245, 102),
Orientation = FlowPanelOrientation.Vertical
};
// add the text block to contain the first message
panel.Elements.Add(new TextBlock
{
ElementId = (short) TileMessagesLayoutElementId.Message1,
Rect = new PageRect(0, 0, 245, 102),
// left, top, right, bottom margins
Margins = new Margins(15, 0, 15, 0),
Color = new BandColor(0xFF, 0xFF, 0xFF)
});
// add the text block to contain the second message
panel.Elements.Add(new TextBlock
{
ElementId = (short)TileMessagesLayoutElementId.Message2,
Rect = new PageRect(0, 0, 245, 102),
// left, top, right, bottom margins
Margins = new Margins (15, 0, 15, 0),
Color = new BandColor(0xFF, 0xFF, 0xFF)
});
// add the text block to contain the third message
panel.Elements.Add(new TextBlock
{
ElementId = (short)TileMessagesLayoutElementId.Message3,
Rect = new PageRect(0, 0, 245, 102),
// left, top, right, bottom margins
Margins = new Margins(15, 0, 15, 0),
Color = new BandColor(0xFF, 0xFF, 0xFF)
});
// create the page layout
var layout = new PageLayout(panel);
tile.PageLayouts.Add(layout);
}
public async Task UpdateLeaderBoard(IBandClient bandClient)
{
// create the object containing the page content to be set
var pageContent = new PageData(MSC_LEADERBOARD_GUID, 0,
new TextBlockData((Int16) TileMessagesLayoutElementId.Message1,
"This is the text of the first message"),
new TextBlockData((Int16) TileMessagesLayoutElementId.Message2,
"This is the text of the second message")
,
new TextBlockData((Int16) TileMessagesLayoutElementId.Message3,
"This is the text of the third message")
);
var added = await bandClient.TileManager.SetPagesAsync(MSC_TILE_GUID, pageContent);
}
如果 MSC_LEADERBOARD_GUID 是一个常量,那可能就是问题所在。每个 PageData 都需要一个唯一的 Guid。如果您的图块上只有一个页面,这应该不是问题,但更改它可能值得一试。
每页最多只能有一个 TextBlock / WrappedTextBlock 的字符串超过 20 个字符。尝试减少页面数据 TextBlock 字符串中的字符数,看看是否有帮助。
我在 bandClient.TileManager.SetPagesAsync 返回 true 时遇到问题,我认为这意味着一切都成功了,但是当我单击我的 band 磁贴时,没有任何显示。我省略了下面的磁贴创建代码,因为我相信它工作正常,因为我能够成功地向它发送消息。有什么想法吗?
private void CreateLeaderboardPageLayout(BandTile tile)
{
// create a scrollable vertical panel that will hold 3 text messages
ScrollFlowPanel panel = new ScrollFlowPanel
{
Rect = new PageRect(0, 0, 245, 102),
Orientation = FlowPanelOrientation.Vertical
};
// add the text block to contain the first message
panel.Elements.Add(new TextBlock
{
ElementId = (short) TileMessagesLayoutElementId.Message1,
Rect = new PageRect(0, 0, 245, 102),
// left, top, right, bottom margins
Margins = new Margins(15, 0, 15, 0),
Color = new BandColor(0xFF, 0xFF, 0xFF)
});
// add the text block to contain the second message
panel.Elements.Add(new TextBlock
{
ElementId = (short)TileMessagesLayoutElementId.Message2,
Rect = new PageRect(0, 0, 245, 102),
// left, top, right, bottom margins
Margins = new Margins (15, 0, 15, 0),
Color = new BandColor(0xFF, 0xFF, 0xFF)
});
// add the text block to contain the third message
panel.Elements.Add(new TextBlock
{
ElementId = (short)TileMessagesLayoutElementId.Message3,
Rect = new PageRect(0, 0, 245, 102),
// left, top, right, bottom margins
Margins = new Margins(15, 0, 15, 0),
Color = new BandColor(0xFF, 0xFF, 0xFF)
});
// create the page layout
var layout = new PageLayout(panel);
tile.PageLayouts.Add(layout);
}
public async Task UpdateLeaderBoard(IBandClient bandClient)
{
// create the object containing the page content to be set
var pageContent = new PageData(MSC_LEADERBOARD_GUID, 0,
new TextBlockData((Int16) TileMessagesLayoutElementId.Message1,
"This is the text of the first message"),
new TextBlockData((Int16) TileMessagesLayoutElementId.Message2,
"This is the text of the second message")
,
new TextBlockData((Int16) TileMessagesLayoutElementId.Message3,
"This is the text of the third message")
);
var added = await bandClient.TileManager.SetPagesAsync(MSC_TILE_GUID, pageContent);
}
如果 MSC_LEADERBOARD_GUID 是一个常量,那可能就是问题所在。每个 PageData 都需要一个唯一的 Guid。如果您的图块上只有一个页面,这应该不是问题,但更改它可能值得一试。
每页最多只能有一个 TextBlock / WrappedTextBlock 的字符串超过 20 个字符。尝试减少页面数据 TextBlock 字符串中的字符数,看看是否有帮助。