作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的目标是 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/
我的目标是 Windows 10,最新的操作系统版本。我从 Microsoft 自适应 toast 示例中复制/粘贴了一些内容——包括路径。这是我的代码: public void CreateToas
我是一名优秀的程序员,十分优秀!