Search code examples
c#uwplive-tile

Set Adaptive Tile Background from Image


I am creating a TileNotification to display the last edited project on my app's tile. When doing this I want to set the tile's background to be the project cover image. I'm creating the TileContent like this:

TileContent content = new TileContent()
{
    Visual = new TileVisual()
    {
        TileMedium = new TileBinding()
        {
            Content = new TileBindingContentAdaptive()
            {
                BackgroundImage = new TileBackgroundImage()
                {
                    Source = new TileImageSource("ms-appx:///Assets/Images/MainPageBackground.jpg"),
                    Overlay = 10
                },

                Children =
                {
                    new TileText()
                    {
                        Text = DataModel.Instance.CurrentProject.Title,
                        Align = TileTextAlign.Left
                    }
                }
            }
        }
    }
};

The problem is that the only way to set the Source property seems to be with a TileImageSource, which only accepts a string. And since the project's cover image is stored in ApplicationData.Current.LocalFolder... I can't just give it a string. Is there any way to set the image source from an actual image rather than a string?


Solution

  • After some more searching I found this method of doing it.

    You can use the "ms-appdata:///Local" prefix to get the file. In my case:

    $"ms-appdata:///local/Projects/{ProjectName}/Slides/0.gif".

    That can then be handed in as the source.