Reputation: 2227
I'd like to show a toast notification using an image either from a Bitmap or thumbnail of a local file. The examples only show images from a web url. How can I directly set the image using a Bitmap?
Edit: Apparently ms-appdata does not work either. Based on the documentation here: https://learn.microsoft.com/en-us/windows/uwp/controls-and-patterns/tiles-and-notifications-adaptive-interactive-toasts, as well as my own testing, only url src is accepted?
Upvotes: 1
Views: 1363
Reputation: 3237
Actually, every file stored inside the app's folders (Windows.Storage.ApplicationData.Current.RoamingFolder
, Windows.Storage.ApplicationData.Current.TemporaryFolder
, Windows.Storage.ApplicationData.Current.LocalFolder
) has it's one ms-appdata://
uri.
So, I would suggest you to write the Bitmap file locally in the TemporaryFolder
and use the ms-appdata://
uri as follows: ms-appdata:///temp/{imagename}.png
More info here: Create, write, and read a file - Microsoft Docs
EDIT
Here, you can see how the schema of the Toast content is, and it says that you can use a local URI in the ms-appdata
format as an image inside a Toast Notification.
Example for Hero images inside it (If you are specifying the Toast in C# instead of xml):
new ToastBindingGeneric() //The toast you want to show
{
HeroImage = new ToastGenericHeroImage()
{
Source = "ms-appdata:///temp/yoursavedimage.png" //This is the image stored locally
}
}
Upvotes: 3