none
Using ToastNotifications in a standalone Console C# application -> Hide ApplicationId RRS feed

  • Question

  • Hi!

    I managed to show a toast notifier in a standard console C# application. The function is like this:

            static void ShowImageToast(string appId, string title, string message, string image)
            {
                XmlDocument toastXml = ToastNotificationManager.GetTemplateContent(
                    ToastTemplateType.ToastImageAndText02);
                // Fill in the text elements
                XmlNodeList stringElements = toastXml.GetElementsByTagName("text");
                stringElements[0].AppendChild(toastXml.CreateTextNode(title));
                stringElements[1].AppendChild(toastXml.CreateTextNode(message));
    
                // Specify the absolute path to an image
                String imagePath = "file:///" + image;
                XmlNodeList imageElements = toastXml.GetElementsByTagName("image");
                imageElements[0].Attributes.GetNamedItem("src").NodeValue = imagePath;
    
                // Create the toast and attach event listeners
                ToastNotification toast = new ToastNotification(toastXml);
    
                ToastEvents events = new ToastEvents();
    
                toast.Activated += events.ToastActivated;
                toast.Dismissed += events.ToastDismissed;
                toast.Failed += events.ToastFailed; 
     ToastNotificationManager.CreateToastNotifier(appId).Show(toast);
            }
    
    

    The problem is that the Application ID appears at the bottom of the toast.

    I know there is a branding XML modifier (for the visual and the binding nodes) and if you set it to "none" then it should be hidden but it's not working.

    Is there any way to achieve this?

    Thanks

    Thursday, December 5, 2019 2:44 PM

All replies

  • Hi,

    Thanks for posting here.

    Since this case is related to C#, so this thread will be moved to C# forum for better support.

    Best regards,

    Jeffrey


    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, December 6, 2019 5:47 AM
  • Hi pablo_1975,

    Thank you for posting here.

    I have a question to confirm, how can I use the UWP API in the Console App?

    Could you please tell me about it so that I can reproduce your problem?

    I look forward to hearing from you.

    Best Regards,

    Timon


    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, December 6, 2019 7:44 AM
  • For example see:

    https://github.com/psantosl/ConsoleToast

    There are ways by manually adding the references...

    Friday, December 6, 2019 12:15 PM
  • Hi pablo_1975,

    Thanks for your feedback.

    Although I successfully reproduced the problem, I failed to resolve it.

    I think this may be the problem caused by the UWP API.

    I am not proficient in UWP, so I suggest that you can ask this question in Microsoft Q&A, they may be able to give you better suggestions.

    Best Regards,

    Timon


    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.

    Tuesday, December 10, 2019 2:25 AM