Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I used the toast notifications for desktop app since Windows 8.1 but with the new action center in Windows 10, I am experiencing some unexpected behaviours.

When the user do nothing with the toast, it simply disappear without going to the action center (ToastNotification.Dismissed is ToastDismissalReason.TimedOut). I don't know if it related to the fact that I use it in a win32 app but the same toast in a Windows Universal App goes to the action center when it timed out.

One thing to note is that I have not registered an AppUserModelID for my win32 app like it was needed in W8.1, it seems to not be mandatory anymore. I still tested with a registered id, and I had the same popblem.

So, how can i prevent the toast from not going in the action center when it timed out ?

Here is a minimalist code (console app) that reproduces the issue :

using Windows.Data.Xml.Dom;
using Windows.UI.Notifications;

namespace ToastDesktop
{
    internal class Program
    {
        /// Add in the .csproj in the <PropertyGroup/> where <TargetFrameworkVersion/> is:
        /// <TargetPlatformVersion>10.0.10240.0</TargetPlatformVersion>
        ///
        /// Reference to add :
        /// - Windows.UI
        /// - Windows.Data
        private static void Main(string[] args)
        {
            string xml = $@"
                <toast>
                    <visual>
                        <binding template='ToastGeneric'>
                            <text>Some title</text>
                            <text>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</text>
                        </binding>
                    </visual>
                </toast>";

            XmlDocument doc = new XmlDocument();
            doc.LoadXml(xml);

            ToastNotification toast = new ToastNotification(doc);
            toast.Tag = "tag";
            toast.Group = "group";

            ToastNotificationManager.CreateToastNotifier("ToastDesktop").Show(toast);
        }
    }
}

Thanks for your help.

Edit : I posted this bug on the msdn blog post that cover the subject and I got the confirmation that it should remain in the action center when timed out and that it might be a bug.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
461 views
Welcome To Ask or Share your Answers For Others

1 Answer

Win32 apps need to set up a COM server in order to have toasts persisted in Action Center: http://blogs.msdn.com/b/tiles_and_toasts/archive/2015/10/15/quickstart-handling-toast-activations-from-win32-apps-in-windows-10.aspx


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...