简体   繁体   English

如何为应用程序磁贴设置初始值

[英]How to set initial values for the Application Tile

I would like my application tile to have the flip animation, and I have attempted to set these values in the codebehind of my MainPage, but for some reason the Application Tile does not perform the flip animation. 我希望我的应用程序磁贴具有翻转动画,并且尝试在MainPage的代码隐藏区中设置这些值,但是由于某些原因,应用程序磁贴不执行翻转动画。 I believe I set the back side values properly. 我相信我正确设置了背面值。 What I have is as follows: 我所拥有的如下:

MainPage.xaml.cs MainPage.xaml.cs

public void CreateApplicationTile()
    {
        var appTile = ShellTile.ActiveTiles.First();

        if (appTile != null)
        {
            var standardTile = new StandardTileData
            {
                Title = "ShareSky",
                BackgroundImage = new Uri("/Background.png", UriKind.Relative),
                BackTitle = "ShareSky",
                BackBackgroundImage = new Uri("/Background.png", UriKind.Relative),
                //BackContent = "click me!"                    
                BackContent = AppResource.Main_MainPage_ApplicationTile_BackContent
            };

            appTile.Update(standardTile);
        }
    }

As I understand, this method does not need to be associated with any events of any type (such as a click) to make it work. 据我了解,此方法无需与任何类型的任何事件(例如单击)相关联即可使其起作用。 I am unsure of what I am doing wrong here? 我不确定自己在做什么错吗? If I have to edit the WMAppManifest file, how would I correctly do this to incorporate the backside of the tile information? 如果必须编辑WMAppManifest文件,如何正确地合并图块信息的背面?

Silly question but are you actually calling "CreateApplicationTile" in your constructor? 愚蠢的问题,但是您实际上在构造函数中调用了“ CreateApplicationTile”吗? If you didn't it would never activate. 如果您不这样做,它将永远不会激活。

    public MainPage()
    {
        InitializeComponent();
        CreateApplicationTile();
    }

I ran the following and got the nice happy rollovers. 我跑了以下,并得到了愉快的过渡。

   var appTile = ShellTile.ActiveTiles.FirstOrDefault(x => x.NavigationUri.ToString() == "/");
   if (appTile != null)
   {
        var standardTile = new StandardTileData
        {
                Title = "ShareSky",
                BackgroundImage = new Uri("/Background.png", UriKind.RelativeOrAbsolute),
                BackTitle = "ShareSky",
                BackBackgroundImage = new Uri("/flipped.png", UriKind.RelativeOrAbsolute),
                BackContent = "backcontent load"
        };

        appTile.Update(standardTile);
     }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM