Windows phone 7在前台使用应用程序进行Toast通知

快问。 我这样做了:

myChannel.ShellToastNotificationReceived += new EventHandler(myChannel_ShellToastNotificationReceived); 

因此,如果我在应用程序位于前台时收到Toast通知,则应调用myChannel_ShellToastNotificationReceived函数。 在那个function中,我有:

 void myChannel_ShellToastNotificationReceived(object sender, NotificationEventArgs e) { Dispatcher.BeginInvoke(() => { ApplicationTitle.Text = "Toast Notification Message Received"; }); } 

问题是永远不会调用该函数,并且永远不会更改ApplicationTitle。

我做错了吗?

我发现了问题……似乎正在发送的吐司xml已经足够格式化,因此手机会从应用程序中接收它,但不会在它内部接收它。 用“手”写了xml并且没有使用xmlWriter并且工作了。

 string toastMessage = "" + "" + "" + "" + title + "" + "" + message + "" + "" + ""; 

您的频道是否已注册接收通知?