C# 从图像设置自适应平铺背景

C# 从图像设置自适应平铺背景,c#,uwp,live-tile,C#,Uwp,Live Tile,我正在创建一个TileNotification,以在我的应用程序的tile上显示上次编辑的项目。执行此操作时,我希望将互动程序的背景设置为项目封面图像。我正在创建TileContent,如下所示: TileContent content = new TileContent() { Visual = new TileVisual() { TileMedium = new TileBinding() { Content = ne

我正在创建一个
TileNotification
,以在我的应用程序的tile上显示上次编辑的项目。执行此操作时,我希望将互动程序的背景设置为项目封面图像。我正在创建
TileContent
,如下所示:

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

问题是设置
Source
属性的唯一方法似乎是使用
TileImageSource
,它只接受字符串。由于该项目的封面图像存储在
ApplicationData.Current.LocalFolder…
中,我不能给它一个字符串。有没有办法从实际图像而不是字符串设置图像源?

经过进一步搜索,我找到了这种方法

您可以使用“ms”-appdata:///Local“获取文件的前缀。就我而言:

$”毫秒-appdata:///local/Projects/{ProjectName}/Slides/0.gif”


然后可以将其作为来源提交。

很高兴你找到了它!注意。。。通常,“local”是小写,如
ms-appdata:///local/
。有关更多信息,您可以访问