Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UWP Toast works, but images (AdaptiveImage, ToastGenericHeroImage, ToastGenericAppLogo) not displaying

I am targeting Windows 10, latest OS build. I copy/pasted some stuff from the Microsoft adaptive toast examples--including the paths. Here's my code:

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

The toast displays, but the images do not. Anyone have an idea?


EDIT: As @AVK suggested I decided to give it a shot using XML instead; unfortunately I get the same behavior -- toast shows, but no images. Here's my code for that (though admittedly I know even less about XML, so this code could be wrong-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);
like image 658
codeMonkey Avatar asked Oct 26 '25 21:10

codeMonkey


2 Answers

Http images are only supported in Desktop Bridge apps that have the internet capability in their manifest. Classic Win32 apps do not support http images; you must download the image to your local app data and reference it locally.

like image 60
Nuno Santos Avatar answered Oct 29 '25 10:10

Nuno Santos


This is a Windows 10 bug that causes Toast Notification for applications to not show images.

Run the troubleshooter for Windows apps could fix it.

like image 21
BlackGlory Avatar answered Oct 29 '25 12:10

BlackGlory



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!