1

I am trying to build an unpackaged WPF app with Windows 10 Toast Notifications. I would like to make an AppLogoOverride to get a resource from the Resources class of my application. I have tried to do this so far:

public void ShowToast() {
  var toast = new ToastContentBuilder()
    .AddText("Foo!")
    .AddText("Bar.")
    .AddAppLogoOverride(new Uri("pack://application:,,,/Resources/foobar.png"), ToastGenericAppLogoCrop.Circle)
    .SetToastScenario(ToastScenario).Reminder);
  ToastNoticiationManagerCompat.CreateToastNotifier().Show(toast);
}

When doing so, the notification just says the generic "New Notification" text. So I tried commenting out the part that says AddAppLogoOverride, and it started to work. So I am not sure how to get the image from Resources.

I would also like to mention that there is no way for me to use something like ms-appdata:// or others, I am not sure how to go about doing this, and I really don't want to write the file locally to the disk.

thakyZ
  • 113
  • 1
  • 2
  • 12
  • Pack URIs are not supported in toast notifications. – mm8 May 23 '22 at 12:13
  • You *could* use `ms-appx`, but that requires a MSIX package... `ms-appdata` is, well, a file. Then of course you have `file:///` and `http://` or `https://`, which are still files. You decide :) – Jimi May 24 '22 at 08:57
  • Sadly, I am trying to load it from memory or something like a data-uri. So far I have just made a cache system, but I'd rather not write everything to a file. – thakyZ Jun 13 '22 at 14:40

1 Answers1

1

I have not succeeded to include an image into a toast using pack://application:,,, syntax so far. I guess this syntax is not supported by toast notification because it is a part of WinRT and the syntax of UWP to refer resources is different from that of WPF.

The workaround is, you might dislike it, to copy the image in local (in the installation folder of the app or somewhere else) and specify its absolute path. See How can I make a notification in a C# Windows app with a custom image and onclick function?

emoacht
  • 2,764
  • 1
  • 13
  • 24