Mango Application Tile - remove back

后端 未结 3 1586
逝去的感伤
逝去的感伤 2021-01-07 18:44

This is a simple question, and a seemingly simple task but I can\'t find any info on how to accomplish what I need to do.

I have an application whose main tile (wh

3条回答
  •  别那么骄傲
    2021-01-07 19:38

    OK, I think I've got it, and it appears to be related to a change in the way tile data is handled...

    Previously, setting a value to an empty string would have now effect in the tile. For eaxmple, setting title = string.Empty would leave the existing title in place. Now, though, it will blank out the title. That's good - it means I can remove BackTitle and BackContent string easily. We're half way there.

    Now, to get rid of the BackBackgroundImage, the documentation states "If set to an empty URI, the BackBackgroundImage will not be displayed." - all good, except you can't create an empty Uri in any simple way. The one way I've made it work is to set it to a Uri value that doesn't exist, eg

    BackBackgroundImage = new Uri("obviouslyMadeUpLocation", UriKind.Relative);
    

    I would have expected that to throw an exception when you try to apply it to the tile, but it doesn't - it just clears the background image.

    So that's it. All I appear to need to do is to call the following to unset these properties and put my tile back as it was.

    private void ResetMyMainTile()
    {
        ShellTile tile = ShellTile.ActiveTiles.First();
        StandardTileData data = new StandardTileData
        {
            BackBackgroundImage = new Uri("IDontExist",UriKind.Relative),
            BackContent = string.Empty,
            BackTitle = string.Empty
        };
        tile.Update(data);
    }
    

提交回复
热议问题