locked
[UWP]App icon at a UWP toast from C# RRS feed

  • Question

  • Hi,

    I'm just playin around with the UWP Community Toolkit in C#.

    I want to set the app icon (icon of the left side of the toast) of a toast but I couldn't find anything at the docs.

    Does anyone know how to do this from C#?

    https://www.pic-upload.de/view-33696044/Toast.png.html



    • Edited by Lu05 Tuesday, August 8, 2017 4:45 AM
    • Edited by Xavier Xie-MSFT Wednesday, August 9, 2017 2:05 AM add title tag
    Tuesday, August 8, 2017 4:44 AM

All replies

  • Hi, Lu05

    Welcome to the Developing Universal Windows apps forum!

    Please read the sticky posts, especially the Guide to posting: subject line tags and Known Issues for Windows 10 SDK and Tools 

    If you want to set the image of the Toast you can add code below:

    <toast launch="developer-defined-string">
      <visual>
        <binding template="ToastGeneric">
          <text>Toast Title</text>
          <text>Content about some words</text>
          <image placement="appLogoOverride" src="Assets/Images/YourOwnImage.png"/>
        </binding>
      </visual>
    </toast>
    

    placement="appLogoOverride" means you set the image as an icon at the left side of Toast. You can also set the image without the property. Then the image will be a part of the content of the toast below the text. Then save this file as a XML file and show the toast notification like

    var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync("XMLFile.xml");
    var xmlDoc = await XmlDocument.LoadFromFileAsync(file);
    ToastNotification notification = new ToastNotification(xmlDoc);
    ToastNotificationManager.CreateToastNotifier().Show(notification);
    

    More details please reference the official sample

    Best Regards,

    Xavier Eoro



    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Azat Tazayan Wednesday, August 9, 2017 6:48 AM
    Wednesday, August 9, 2017 2:07 AM
  • Hi Xavier,

    thanks for your reply but thats not what I was looking for.

    I have working toasts with images.

    But I need to set the icon for the app header of multiple toasts.

    I read about that there is a bug and the icon ist not showing while debugging with visual studio but at the release build I dont' have the icon either.

    I set the icon at the project properties. At the task bar the icon is correct.

    Do I have do do something special to show the icon at the toast header?

    Thanks for your help.


    • Edited by Lu05 Wednesday, August 9, 2017 12:51 PM
    Wednesday, August 9, 2017 12:51 PM
  • Hi Lu05,

    I also faced this issue in the past. Please check if you have set all visual assets correctly in “Package.appxmanifest”. If you make sure that all assets were correct. Then, please ignore this issue when debugging in your local (no matter debug/release mode). Once you published your app to the windows store and installed it from windows store, then the icon will show correctly in toast.

    Best Regards,

    Xavier Eoro


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, August 10, 2017 3:07 AM
  • Yeah maybe thats the problem.

    I don`t have a UWP app with a Package.appxmanifest.

    I have a WPF app and use the UWP Community Toolkit to send toasts to the action center.

    Is there any example on how to do that for WPF?

    Thursday, August 10, 2017 4:59 AM
  • Hi Lu,

    If you're sending toast from desktop app, please follow the instructions described here: https://blogs.msdn.microsoft.com/tiles_and_toasts/2015/10/16/quickstart-handling-toast-activations-from-win32-apps-in-windows-10/ 

    Here's a code sample for your reference: https://github.com/WindowsNotifications/desktop-toasts 

    Best Regards,

    Xavier Eoro


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, August 11, 2017 9:01 AM