<PropertyGroup>
<!-- You can also target other versions of the Windows SDK and .NET; for example, "net6.0-windows10.0.19041.0" -->
<TargetFramework>net6.0-windows10.0.22000.0</TargetFramework>
</PropertyGroup>
// Initialize the tile with required arguments
var tile = new Windows.UI.StartScreen.SecondaryTile(
"myTileId5391",
"Display name",
"myActivationArgs",
new Uri("ms-appx:///Assets/Square150x150Logo.png"),
TileSize.Default);
// Initialize the tile with required arguments
var tile = new Windows.UI.StartScreen.SecondaryTile(
"myTileId5391",
"Display name",
"myActivationArgs",
new Uri("ms-appx:///Assets/Square150x150Logo.png"),
TileSize.Default);
var wih = new System.Windows.Interop.WindowInteropHelper(this);
var hWnd = wih.Handle; // For a WinForms window object, access the NativeWindow.Handle property instead.
IInitializeWithWindow initWindow = (IInitializeWithWindow)(object)tile;
initWindow.Initialize(hWnd);
最后,请求像在普通 UWP 应用中一样固定磁贴。
// Pin the tile
bool isPinned = await tile.RequestCreateAsync();
// Here, update UI to reflect whether user can now either unpin or pin