gpt4 book ai didi

c# - UWP Toast 有效,但图像(AdaptiveImage、ToastGenericHeroImage、ToastGenericAppLogo)不显示

转载 作者:行者123 更新时间:2023-11-30 15:17:29 25 4
gpt4 key购买 nike

我的目标是 Windows 10,最新的操作系统版本。我从 Microsoft 自适应 toast 示例中复制/粘贴了一些内容——包括路径。这是我的代码:

public void CreateToast(ToastViewModel model)
{
ToastContent content = new ToastContent()
{
Launch = "app-defined-string",

Visual = new ToastVisual()
{
BindingGeneric = new ToastBindingGeneric()
{
Children =
{
new AdaptiveText()
{
Text = "Photo Share"
},

new AdaptiveText()
{
Text = "Andrew sent you a picture"
},

new AdaptiveText()
{
Text = "See it in full size!"
},

new AdaptiveImage()
{
Source = "https://unsplash.it/360/180?image=1043"
}
},
HeroImage = new ToastGenericHeroImage()
{
Source = "https://unsplash.it/360/180?image=1043"
},
AppLogoOverride = new ToastGenericAppLogo()
{
Source = "https://unsplash.it/64?image=883",
HintCrop = ToastGenericAppLogoCrop.Circle
}
}
}
};

var toast = new ToastNotification(content.GetXml());
toast.Failed += (o, args) =>
{
var message = args.ErrorCode;
};

ToastNotificationManager.CreateToastNotifier().Show(toast);
}

toast 显示,但图像不显示。有人有想法吗?


编辑:正如@AVK 建议的那样,我决定尝试使用 XML 来代替它;不幸的是,我得到了同样的行为—— toast 显示,但没有图像。这是我的代码(尽管我对 XML 的了解甚至更少,所以这段代码可能是错误的):

var template = ToastTemplateType.ToastImageAndText02;
var xml = ToastNotificationManager.GetTemplateContent(template);
var elements = xml.GetElementsByTagName("text");
var text = xml.CreateTextNode(model.Title);
elements[0].AppendChild(text);
var images = xml.GetElementsByTagName("image");
var srcAttribute = xml.CreateAttribute("src");
srcAttribute.Value = "https://unsplash.it/64?image=883";
images[0].Attributes.SetNamedItem(srcAttribute);
var toast = new ToastNotification(xml);
ToastNotificationManager.CreateToastNotifier().Show(toast);

最佳答案

只有在其 list 中具有互联网功能的桌面桥应用程序才支持 Http 图像。经典 Win32 应用程序不支持 http 图像;您必须将图像下载到本地应用程序数据并在本地引用它。

关于c# - UWP Toast 有效,但图像(AdaptiveImage、ToastGenericHeroImage、ToastGenericAppLogo)不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46246430/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com