芒果应用瓷砖 - 删除回来 [英] Mango Application Tile - remove back

查看:24
本文介绍了芒果应用瓷砖 - 删除回来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个简单的问题,也是一个看似简单的任务,但我找不到任何关于如何完成我需要做的事情的信息.

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.

我有一个应用程序,其主磁贴(固定时)有时需要是默认的单面磁贴,有时需要在磁贴背面显示信息.我可以从 ScheduledActionService 成功添加 BackBackgroundImage、BackContent 和 BackTitle,但是当不再需要它们时,我无法删除它们.这不是辅助磁贴,因此我无法将其移除并重新创建和重新添加.

I have an application whose main tile (when pinned) sometimes needs to be the default, single sided tile and sometimes needs to have information displayed on the back of the tile. I can add the BackBackgroundImage, BackContent and BackTitle successfully from the ScheduledActionService, but I can't remove them when they are no longer required. This isn't a secondary tile so I can't remove it and re-create and re-add it.

有谁知道是否可以通过代码将双面瓷砖恢复为单面,如果可以,我该如何实现这种行为?

Does anyone know if it is possible to revert a double-sided tile back to single-sided via code, and if so, how can I achieve that behaviour, please?

编辑

从 StandardTileData 对象应用的设置是附加的 - 例如,如果您指定一个标题,则所有其他元素保持不变,仅更新标题.我试图将出现在磁贴背面的三个参数设置为 null 并取得了部分成功.效果是背景图片、标题文字和内容文字都被去除了,但磁贴仍然翻转显示一个完全空的反面.

The settings that get applied from the StandardTileData object are additive - if you only specify a title, for example, all other elements remain the same and only the title is updated. I have attempted to set the three parameters that appear on the back of the tile to null and had partial success. The effect is that the background image, title text and content text are all removed, but the tile still flips over to show a completely empty reverse side.

再次编辑

因此,查看文档,瓷砖背面的行为与正面不同.将 back content 或 backtitle 设置为 string.Empty 将删除它们.那里一切都很好.但是,它确实说如果设置为空 URI,则不会显示 BackBackgroundImage.".我如何去创建一个空的 Uri?我尝试了 new Uri(string,Empty) 但这会引发关于尝试创建空 Uri 的异常 - 这就是我正在尝试做的.

So, looking at the documentation, the tile back behaves differently to the front. Setting the back content or backtitle to string.Empty will remove those. All good there. However, it does say that "If set to an empty URI, the BackBackgroundImage will not be displayed.". How do I go about creating an empty Uri? I tried new Uri(string,Empty) but that throws an exception about trying to create an empty Uri - which is what I'm trying to do.

推荐答案

好的,我想我明白了,它似乎与瓦片数据处理方式的变化有关...

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

以前,将值设置为空字符串现在会在磁贴中生效.例如,设置 title = string.Empty 将保留现有标题.但是,现在它会使标题空白.这很好 - 这意味着我可以轻松删除 BackTitle 和 BackContent 字符串.我们已经完成了一半.

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.

现在,为了摆脱 BackBackgroundImage,文档指出如果设置为空 URI,则不会显示 BackBackgroundImage."- 一切都很好,除了你不能以任何简单的方式创建一个空的 Uri.我让它工作的一种方法是将它设置为一个不存在的 Uri 值,例如

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);
}

这篇关于芒果应用瓷砖 - 删除回来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆