Search code examples
c#xamluap

How to animate live tiles using notification extensions?


I want to animate lives tiles in UAP applications. But I am getting this exception:

Cannot implicitly convert type 'NotificationsExtensions.Tiles.TileImageSource' to 'string'.

I am using this code:

TileBindingContentAdaptive largebindingContent = new TileBindingContentAdaptive()
{
    PeekImage = new TilePeekImage()
    {
        Source = new TileImageSource("Assets/Apps/Hipstame/hipster.jpg")
    },
    Children =
    {
        new TileText() {Text =Description, Wrap = true, Style = TileTextStyle.BodySubtle}
    }
};

How can I animate my live tiles?


Solution

  • Cannot implicitly convert type 'NotificationsExtensions.Tiles.TileImageSource' to 'string'.

    The reason you are getting this exception is because as of May 2016 NotificationsExtensions received some updates where there have been changes made to TileBackgroundImage and TilePeekImage. You can see the details of these changes here in the msdn update post.

    Specifically, the property type for Source changed from TileImageSource to string. This change means that you need to change the way you are setting Source. Note in the code below (yours, which I modified) where the Source is simply a string. This should resolve the exception you are getting.

    TileBindingContentAdaptive largebindingContent = new TileBindingContentAdaptive()
    {
        PeekImage = new TilePeekImage()
        {
            Source = "Assets/Apps/Hipstame/hipster.jpg"
        },
    
        Children =
        {
            new TileText() 
            {
                Text = Description,
                Wrap = true,
                Style = TileTextStyle.BodySubtle
            }
        } 
    };
    

    As far as animating your live tiles there are a variety of things you can do and I cannot give any specific advice unless you specify what you want to do with your tiles. For example, if you want to cycle through images in your live tile you can take a look at this example here for cycling multiple images with an animation through a live tile. You can also refer to the msdn Adaptive Tile Templates documentation if you want to read through in more detail about what else you can do with your tiles.