如何从Windows Store应用程序中的SecondaryTile导航到特定页面?
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了如何从Windows Store应用程序中的SecondaryTile导航到特定页面?,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1998字,纯文字阅读大概需要3分钟。
内容图文
![如何从Windows Store应用程序中的SecondaryTile导航到特定页面?](/upload/InfoBanner/zyjiaocheng/948/7bbc786487c4443099b8a6f71d501e7c.jpg)
我目前正在使用C#开发Windows Store应用程序.在我的应用程序中,我正在使用“辅助平铺”选项使用以下代码将我的功能之一固定到“开始”屏幕.
if (SecondaryTile.Exists(TileId))
{
var secondaryTile = new SecondaryTile(TileId);
await econdaryTile.RequestDeleteForSelectionAsync(GetElementRect((FrameworkElement)sender), Placement.Above);
}
else
{
var logo = new Uri("ms-appx:///Assets/A.png", UriKind.RelativeOrAbsolute);
var secondaryTile = new SecondaryTile
{
Logo = logo,
TileId = TileId,
ShortName = "AAAA",
Arguments = TileId + DateTime.Now.ToLocalTime(),
DisplayName = "AAAAAAA BBBBBBB",
TileOptions = TileOptions.ShowNameOnLogo,
ForegroundText = ForegroundText.Dark
};
await secondaryTile.RequestCreateForSelectionAsync(GetElementRect(sender as FrameworkElement), Placement.Above);
}
因此,它现在将SecondaryTile托管到“开始”屏幕.但是根据我的要求,每当用户从“开始”屏幕中单击SecondaryTile时,它都应导航到页面“ A”.我们可以在Windows Store应用程序中实现这一目标吗?
解决方法:
是的,但是您应该使用另一个SecondaryTile构造函数来传递一些参数以及tile ID.您不需要使用其他构造函数,因为您可以仅使用Tile ID来确定应用程序启动时必须进入的页面,但我认为最好使用参数发送页面名称或标识.
public SecondaryTile(
string tileId,
string shortName,
string displayName,
string arguments,
TileOptions tileOptions,
Uri logoReference
)
Documentation says that arguments is:
An app-defined string meaningful to the calling application. This
argument string is passed back to the app when the app is activated
from the secondary tile. It will be truncated after 2048 characters.
Can be set or retrieved through the Arguments property
因此,您可以传递一个字符串,该字符串标识当用户单击辅助磁贴时必须启动的页面,然后在激活该应用后在App.xaml.cs OnLaunched方法上使用它:
async protected override void OnLaunched(LaunchActivatedEventArgs args)
{
var tile_id = args.TileId;
var tile_arguments = args.Arguments;
// Depending on tile_id and tile_arguments navigate to the page you want
}
请注意,您还应该注意OnLaunched方法中的args.PreviousExecutionState.您的OnLaunched方法不能只是这个.
内容总结
以上是互联网集市为您收集整理的如何从Windows Store应用程序中的SecondaryTile导航到特定页面?全部内容,希望文章能够帮你解决如何从Windows Store应用程序中的SecondaryTile导航到特定页面?所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。