I'm trying to display Windows 10 Toasts with my WPF C# Desktop application.
Sadly the API and general support concerning Windows 10 notifications in non-UWP or Store apps seems pretty limited and chaotic. Lately the UWP Community Toolkit was published, which seems to try and make things easier for us. There's also this Store app, Notifications Visualizer, which helps in making Toasts like this:
I went on and tried to generated the Toast using C# and the API provided by the UWP Community Toolkit.
using Microsoft.Toolkit.Uwp.Notifications;
ToastContent toastContent = new ToastContent()
{
Visual = new ToastVisual()
{
BindingGeneric = new ToastBindingGeneric()
{
Children =
{
new AdaptiveText()
{
Text = "Matt sent you a friend request"
},
new AdaptiveText()
{
Text = "Hey, wanna dress up as wizards and ride around on our hoverboards together?"
}
},
AppLogoOverride = new ToastGenericAppLogo()
{
Source = "https://unsplash.it/64?image=1005",
HintCrop = ToastGenericAppLogoCrop.Circle
}
}
}
};
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(toastContent.GetContent());
var toast = new ToastNotification(xmlDoc);
ToastNotificationManager.CreateToastNotifier(AppId).Show(toast); // Display toast
Unfortunately, no matter what I try, I seem to be unable to get the same result, the Image is always missing for some reason:
Most information I found concerning these notifications are either outdated or useless. Can someone please shed some light on this? Thank you.