Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何设置通知Windows 8.1 C的单击事件_C#_Wpf_Xaml_Visual Studio 2012_Windows 8.1 - Fatal编程技术网

C# 如何设置通知Windows 8.1 C的单击事件

C# 如何设置通知Windows 8.1 C的单击事件,c#,wpf,xaml,visual-studio-2012,windows-8.1,C#,Wpf,Xaml,Visual Studio 2012,Windows 8.1,我是Windows开发新手,在Visual Studio上使用C和xaml创建了一个Windows 8.1应用程序。我已经创建了一个祝酒词 var template = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02); var element = template.GetElementsByTagName("text")[0]; element.AppendChild(template.Crea

我是Windows开发新手,在Visual Studio上使用C和xaml创建了一个Windows 8.1应用程序。我已经创建了一个祝酒词

var template = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);
var element = template.GetElementsByTagName("text")[0];
element.AppendChild(template.CreateTextNode("INR BUDDY"));
var element1 = template.GetElementsByTagName("text")[1];
element1.AppendChild(template.CreateTextNode("You have a message!"));
//set the toast to appear 30 seconds from now
var date = DateTimeOffset.Now.AddSeconds(1);
var stn = new ScheduledToastNotification(template, date);
notifier.AddToSchedule(stn);
IXmlNode toastNode = template.SelectSingleNode("/toast");
但是,我希望我的用户在单击通知时使用这行代码转移到特定页面

this.Frame.Navigate(typeof(HomeScreenV2));

如何执行此操作?

单击toast通知时,将触发OnLaunched事件,并且添加到通知中的任何参数都将位于Arguments属性中

App.cs

protected override void OnLaunched(LaunchActivatedEventArgs e)
{
   //parameters from Toast
   if (!string.IsNullOrEmpty(e.Arguments))
   {
       string arguments= e.Arguments;

       if (arguments == "Whatever")
       {
           this.Frame.Navigate(typeof(HomeScreenV2));
       }
    }    
}
注意:如果您的toast中未包含启动属性字符串,并且选择toast时应用程序已在运行,则不会触发OnLaunched事件


更多信息请访问

谢谢您的帮助。你得跟我说我是新手。包括这行代码:xmlementtoastnode.setAttributeLanch,{\type\:\toast\,\param1\:\12345\,\param2:将我的toast链接到OnLaunched,就像xaml中的单击事件一样。但是为什么要检查if语句中的if argument==whatever。whatever表示什么只是一个假设的参数检查。很抱歉,混淆了,请在应用程序中将其忽略它不需要: