它在Microsoft Band SDK文档中说使用WriteableBitmap创建磁贴图标,但是如何让它指向我为Tile制作的现有图像?
答案 0 :(得分:7)
如果您的Windows Phone应用程序有一个名为" Assets / Icon1.png"的资产,则该资产可以通过以下内容制作成BandIcon:
using Microsoft.Band;
using Microsoft.Band.Tiles;
using Microsoft.Band.Tiles.Pages;
using Windows.Storage;
using Windows.Storage.Streams;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Media.Imaging;
...
StorageFile imageFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/Icon1.png"));
using (IRandomAccessStream fileStream = await imageFile.OpenAsync(FileAccessMode.Read)
{
WriteableBitmap bitmap = new WriteableBitmap(1,1);
await bitmap.SetSourceAsync(fileStream);
return bitmap.ToBandIcon();
}