按钮未显示的 ToastNotification

问题描述

我正在开发用 VB.NET 编写的 WinForms 桌面应用程序。我设法使用社区工具包显示 UWP ToastNotifications。这可以正常工作并按预期显示 Toast 通知

Imports Microsoft.Toolkit.Uwp.Notifications
Imports Windows.UI.Notifications

Dim template = Toastnotificationmanager.GetTemplateContent(ToastTemplateType.ToastimageAndText04)
Dim textNodes = template.GetElementsByTagName("text")
textNodes.Item(0).InnerText = title
textNodes.Item(1).InnerText = content
Dim imagePath As String = Application.StartupPath & "\Resources\harddrive_white.ico"
Dim imageNode = template.GetElementsByTagName("image")
CType(imageNode.Item(0),Windows.Data.Xml.Dom.XmlElement).SetAttribute("src",imagePath)

Dim notifier = Toastnotificationmanager.CreatetoastNotifier("APPNAMEHERE")
Dim Notification = New ToastNotification(template) With {
    .Tag = id
}
notifier.Show(Notification)

现在我尝试显示带有按钮的通知并使用以下方法处理激活:

Imports Windows.UI.Notifications
Imports Microsoft.Toolkit.Uwp.Notifications

Public Class ToastNotificationWithButtons

    Public Sub New()
        Dim toastContent = New ToastContent
        toastContent.Visual = New ToastVisual
        toastContent.Visual.BindingGeneric = New ToastBindingGeneric
        toastContent.Visual.BindingGeneric.Children.Add(New AdaptiveText With {.Text = "Text goes here"})
        Dim pActions = New ToastActionsCustom
        pActions.Buttons.Add(New ToastButton("Aktualisieren","Aktualisieren") With {
                             .ActivationType = ToastActivationType.Foreground
                             })
        pActions.Buttons.Add(New ToastButtondismiss)
        toastContent.Actions = pActions

        Dim push = New ToastNotification(toastContent.GetXml)
        push.Tag = "UpdatePush"
        AddHandler push.Activated,AddressOf OnActivate
        AddHandler push.Failed,AddressOf OnFailed
        Toastnotificationmanager.CreatetoastNotifier("APPNAMEHERE").Show(push)
    End Sub

这里的第二个代码执行了,但没有抛出任何错误,什么也没有发生。请问有人可以帮忙吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)