如何使用 App.xaml.cs 上的磁贴 ID、操作和激活来固定 Microsoft Edge 网站等辅助磁贴?我想在我的文本编辑器上固定打开的文本文件。
更新
这是我的 Pin 图代码:
string tileId;
string path = ((StorageFile)currentEditBox.Tag).Path;
tileId = "file" + PivotMain.Items.Count;
TileCollection colllaunch = new TileCollection();
var mycoll = colllaunch.coll;
mycoll.Add(tileId, path);
// Use a display name you like
string displayName;
if(PivotMain.SelectedRichEditBoxItem.HeaderTextBlock.Text.Length > 10
&& currentEditBox.Tag != null)
{
displayName = ((StorageFile)currentEditBox.Tag).Name;
}
else
{
displayName = PivotMain.SelectedRichEditBoxItem.HeaderTextBlock.Text;
}
// Provide all the required info in arguments so that when user
// clicks your tile, you can navigate them to the correct content
string arguments = tileId;
var imageUri = new Uri("ms-appx:///Assets/Square150x150Logo.scale-100.png");
// During creation of secondary tile, an application may set additional arguments on the tile that will be passed in during activation.
// Create a Secondary tile with all the required arguments.
var secondaryTile = new SecondaryTile(tileId,
displayName,
arguments,
imageUri, TileSize.Default);
secondaryTile.VisualElements.ShowNameOnSquare150x150Logo = true;
await secondaryTile.RequestCreateAsync();
这是瓷砖收集的代码:
public class TileCollection
{
public Dictionary<string, string> coll = new Dictionary<string, string>();
}
这是针对 OnNavigatedTo 事件(我不能调用打开文件事件,因为它在 MainPage.xaml 上,我将它移到 MainPage 上):
var launchArgs = e.Parameter as Windows.ApplicationModel.Activation.ILaunchActivatedEventArgs;
if(launchArgs != null)
{
TileCollection colllaunch = new TileCollection();
var mycoll = colllaunch.coll;
if (launchArgs.TileId != "App")
{
StorageFile storageFile;
string path;
mycoll.TryGetValue(launchArgs.TileId, out path);
storageFile = await StorageFile.GetFileFromPathAsync(path);
await OpenFile(storageFile);
}
}