locked
Toast Noticifactions in VB RRS feed

  • Question

  • Hello everyone.

    Long time no see.

    I have a problem in displaying a toast notification from my VB Windows Store app. I am using VS 2013 and Windows 8.1

    Here is my MainPage's code :

    Imports Windows.UI.Notifications 'Notifications Namespace
    Imports System.Text
    Imports Windows.Data.Xml.Dom
    
    Public NotInheritable Class MainPage
        Inherits Page
    
        Private tttToastTemplate As ToastTemplateType
        Private xmlToast As XmlDocument = New XmlDocument
        Private tnToast As ToastNotification
        Dim strXML As String
    
        ' Private tnmNotify As ToastNotificationManager 
    
        Private Sub btTextToast1_Click(sender As Object, e As RoutedEventArgs) Handles btTextToast1.Click
            Try
                tttToastTemplate = ToastTemplateType.ToastText01
    
    
                strXML = "<Toast><Visual Version='1'><binding template='ToastText01'><text id='1'>Message 1</text></binding></visual></toast>"
    
                xmlToast.LoadXml(strXML)
    
                tnToast = New ToastNotification(xmlToast)
    
                ToastNotificationManager.CreateToastNotifier().Show(tnToast)
            Catch ex As Exception
                tbError.Text = ex.Message
            End Try
    
        End Sub
    
    End Class

    It gives me the following error : Exception from HRESULT: 0xc00ce6d.

    Google doesn't give me any details concerning this.

    I just want to show a Toast notification from VB. Can anyone help please?

    Thursday, November 7, 2013 8:58 AM

Answers

  • OK, solved it myself. This is what I did :

        Private Sub btTextToast1_Click(sender As Object, e As RoutedEventArgs) Handles btTextToast1.Click
            Try
                tttToastTemplate = ToastTemplateType.ToastText01
                xmlToast = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01)
    
    
                Dim ttTextNode = xmlToast.GetElementsByTagName("text")
                ttTextNode(0).AppendChild(xmlToast.CreateTextNode("Message 1"))
                tnToast = New ToastNotification(xmlToast)
    
                ToastNotificationManager.CreateToastNotifier().Show(tnToast)
            Catch ex As Exception
                tbError.Text = ex.Message
            End Try
    
        End Sub

    Thanks for reading!

    • Marked as answer by Anne Jing Friday, November 8, 2013 2:14 AM
    Thursday, November 7, 2013 9:44 AM