个人资料

跳过导航链接首页 > 博客列表 > 博客正文

UWP 固定任意图片到开始屏幕

分类:

首先要拥有图片权限

					var imgFile=await para.file.CopyAsync(ApplicationData.Current.LocalFolder,"WindowsTile",NameCollisionOption.ReplaceExisting);


					SetupTileAlert(imgFile);
就是把图片复制到app的localFolder中,就可以随意操作了.

然后调用方法:

SetupTileAlert(imgFile);

参考:https://docs.microsoft.com/zh-cn/windows/uwp/design/shell/tiles-and-notifications/secondary-tiles-pinning

简单修改一下即可,如下:

		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什么事了😄


songshizhao
最初发表2019/12/21 21:49:32 最近更新2019/12/21 21:54:17 195
为此篇作品打分
10
   评论