如何在Windows Phone 8.1上创建SecondaryTile?

时间:2014-10-29 14:56:27

标签: windows-phone windows-phone-8.1 secondary-live-tile

我正在尝试在Windows Phone开始屏幕上创建一个Tile。以下代码用于工作但现在却没有。我没有改变任何事情。

    private async static void CreateTile()
    {
        try
        {
            SecondaryTile tileData = new SecondaryTile()
            {
                TileId = "MyTileID",
                DisplayName = "My App Name",
                TileOptions = TileOptions.ShowNameOnLogo,
            };

            tileData.VisualElements.Square150x150Logo = new Uri("ms-appx:///Resources/Images/Tiles/150150.png", UriKind.Absolute);
            tileData.VisualElements.ShowNameOnSquare150x150Logo = true;

            await tileData.RequestCreateAsync();
        }
        catch (Exception ex)
        {

        }
    }

现在它失败并显示错误消息:

The parameter is incorrect.

和以下Stack Trace:

at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at My.Namespace.SplashPage.<CreateTile>d__f.MoveNext()

当我评论所有内容时,我甚至会收到错误,例如:

SecondaryTile tileData = new SecondaryTile()
{
    //TileId = "MyTileID",
    //DisplayName = "My App Name",
    //TileOptions = TileOptions.ShowNameOnLogo,
};

//tileData.VisualElements.Square150x150Logo = new Uri("ms-appx:///Resources/Images/Tiles/150150.png", UriKind.Absolute);
//tileData.VisualElements.ShowNameOnSquare150x150Logo = true;

await tileData.RequestCreateAsync();

所以我不知道哪个参数不正确。可能是什么导致了这个?我该如何解决?

1 个答案:

答案 0 :(得分:1)

尝试这样的事情:

    if (SecondaryTile.Exists(tileID)) await tileData.UpdateAsync();
    else await tileData.RequestCreateAsync();