UWP吐司工作,但图像(AdaptiveImage,ToastGenericHeroImage,ToastGenericAppLogo)不显示
问题描述:
我的目标是Windows 10,最新的操作系统版本。我从Microsoft自适应吐司示例中复制/粘贴了一些东西 - 包括路径。这是我的代码:UWP吐司工作,但图像(AdaptiveImage,ToastGenericHeroImage,ToastGenericAppLogo)不显示
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);
}
吐司显示,但图像没有。任何人有想法?
编辑:作为@AVK建议,我决定使用XML而不是给它一个镜头;不幸的是,我得到了同样的行为 - 敬酒节目,但没有图像。这里是我的代码(但无可否认,我知道即使有关XML的少,所以这个代码可能是错误的-ER):
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);
答
这是导致Toast通知应用程序不显示图像在Windows 10的bug。
+0
谢谢!你有链接可以偶然分享这个bug吗? – codeMonkey
+1
@codeMonkey不幸的是,我没有找到关于这个bug的任何有用的细节,这就是为什么我会找到这个*页面。 –
当你创建实际的XML时做这个工作吗? – AVK
@AVK很好的问题;我会检查出 – codeMonkey
@AVK用XML示例更新 – codeMonkey