Search code examples
c#.netuwpwin-universal-appdesktop-bridge

SecondaryTile.DisplayName not getting updated


I have the following code, which is supposed to update the text of a SecondaryTile.

async Task UpdateTile(SecondaryTile tile, string text)
{
    tile.DisplayName = text;
    await tile.UpdateAsync();
}

This code does work when I create the tile. But later when I try to update it after retrieving it with:

SecondaryTile tile = new SecondaryTile(id);

it doesn't work anymore, though a similar method that updates the same tile's visuals does work. So I know I have the right tile.


Solution

  • I have tested it, the code works well. You could refer to the following code.

    As follows:

    // Initialize a secondary tile with the same tile ID you want to update
    SecondaryTile tile = new SecondaryTile(tileId);
    tile.DisplayName = "xxx";
    // Show the display name on all sizes
    tile.VisualElements.ShowNameOnSquare150x150Logo = true;
    tile.VisualElements.ShowNameOnWide310x150Logo = true;
    tile.VisualElements.ShowNameOnSquare310x310Logo = true;
    await tile.UpdateAsync();