首先要拥有图片权限
var imgFile=await para.file.CopyAsync(ApplicationData.Current.LocalFolder,"WindowsTile",NameCollisionOption.ReplaceExisting); SetupTileAlert(imgFile);就是把图片复制到app的localFolder中,就可以随意操作了.
然后调用方法:
SetupTileAlert(imgFile);
简单修改一下即可,如下:
public static async void SetupTileAlert(StorageFile imagefile) { var tiles = await SecondaryTile.FindAllAsync(); Debug.WriteLine("磁贴数:"+tiles.Count); string tileId = "000"; // Use a display name you like string displayName = "111"; // Provide all the required info in arguments so that when user // clicks your tile, you can navigate them to the correct content string arguments = "222"; // Initialize the tile with required arguments SecondaryTile tile = new SecondaryTile( tileId, displayName, arguments, new Uri($"ms-appdata:///local/{imagefile.Name}"), TileSize.Default); tile.VisualElements.Wide310x150Logo = new Uri($"ms-appdata:///local/{imagefile.Name}"); tile.VisualElements.Square310x310Logo = new Uri($"ms-appdata:///local/{imagefile.Name}"); // Add a small size logo for better looking small tile tile.VisualElements.Square71x71Logo = new Uri($"ms-appdata:///local/{imagefile.Name}"); // Add a unique corner logo for the secondary tile tile.VisualElements.Square44x44Logo = new Uri($"ms-appdata:///local/{imagefile.Name}"); bool isPinned = await tile.RequestCreateAsync(); }
甚至可以自己实时用win2d花一个图片,保存在local folder 贴上去.
然后就开始玩win2d就行了,没xml什么事了😄