Mango Application Tile - remove back

后端 未结 3 1587
逝去的感伤
逝去的感伤 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:24

    This one works for me.

    new Uri("Background.png", UriKind.RelativeOrAbsolute);
    
    ShellTile TileToFind = ShellTile.ActiveTiles.First();
    
            if (TileToFind != null)
            {
    
                StandardTileData NewTileData = new StandardTileData
                {
                    Title ="Status",
                    BackgroundImage = new Uri("Background.png", UriKind.RelativeOrAbsolute),
                    Count = 0,
                    BackTitle = "",
                    BackBackgroundImage = new Uri("doesntexist.png", UriKind.RelativeOrAbsolute),
                    BackContent = ""
                };
    
                TileToFind.Update(NewTileData);
            }
    
    0 讨论(0)
  • 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);
    }
    
    0 讨论(0)
  • 2021-01-07 19:46

    Try setting the whole tile (all details) again to everything as was before / is now but without the background details.

    Update
    Does this not work?:

    ShellTile tile = ShellTile.ActiveTiles.First();
    tile.Update(null);
    

    or

    tile.update(new StandardTileData());
    
    0 讨论(0)
提交回复
热议问题