固定到桌面
Uri logo = new Uri("ms-appx:///Assets/Background.png");
string name ="我的微博"
string arguments = name
SecondaryTile secondaryTile = new SecondaryTile(name, name, name, arguments, TileOptions.ShowNameOnLogo, logo);
secondaryTile.ForegroundText = ForegroundText.Dark;
bool isPinned = await secondaryTile.RequestCreateForSelectionAsync(this.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Below);
#region 固定到桌面的操作。
public static Rect GetElementRect(FrameworkElement element)
{
GeneralTransform buttonTransform = element.TransformToVisual(null);
Point point = buttonTransform.TransformPoint(new Point());
return new Rect(point, new Size(element.ActualWidth, element.ActualHeight));
}
#endregion
//取消固定
//取消固定。
if (Windows.UI.StartScreen.SecondaryTile.Exists("我的微博"))
{
SecondaryTile secondaryTile = new SecondaryTile("我的微博");
bool isUnpinned = await secondaryTile.RequestDeleteForSelectionAsync(BookReader.GetElementRect((FrameworkElement)sender), Windows.UI.Popups.Placement.Below);
}