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 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…