我想C#代码从下面的链接,从一个传统的Windows窗体应用程序转换成VB.NET并运行它:显示的Windows从WinForm应用程序10敬酒
Quickstart: Sending a local toast notification and handling activations from it (Windows 10)
我安装所需的NuGet包和创建下面的代码(请注意我跳过从原来的C#代码中的“动作”部分现在):
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim title As String = "Andrew sent you a picture"
Dim content As String = "Check this out, Happy Canyon in Utah!"
Dim image As String = "http://blogs.msdn.com/cfs-filesystemfile.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-71-81-permanent/2727.happycanyon1_5B00_1_5D00_.jpg"
Dim logo As String = "ms-appdata:///local/Andrew.jpg"
Dim conversationId As Integer = 384928
' Construct the visuals of the toast
'Visual content
Dim visual As New ToastVisual()
Dim TitleText As New ToastText
TitleText.Text = title
Dim BodyTextLine1 As New ToastText
BodyTextLine1.Text = content
Dim InLineImages As New ToastImageSource(image)
Dim LogoImage As New ToastImageSource(logo)
Dim AppLogoOverride As New ToastAppLogo
AppLogoOverride.Source = LogoImage
AppLogoOverride.Crop = ToastImageCrop.Circle
' Add all content into toastcontent
Dim ToastContent As New ToastContent
ToastContent.Visual = visual
'Arguments when the user taps body of toast
ToastContent.Launch = New QueryString() From {{"action", "viewConversation"}, {"conversationId", conversationId.ToString()}}.ToString()
我理解的代码可以更有效,但对于了解它,我离开它现在像这个。
现在的问题是下一行:
Dim Toast As New toastnotification(ToastContent.getXml)
和
ToastNotificationManager.CreateToastNotifier().Show(toast)
我不能宣布吐司作为新toastnotification和ToastContent似乎错过的getXML功能。
ToastNotificationManager无处可寻。
有人可以请指出我在正确的方向吗?
感谢您的帮助!
你导入相应的命名空间按照步骤2中的‘发送举杯’部分? – jmcilhinney
根据我刚刚在MSDN上找到的文档,'ToastNotification'和'ToastNotificationManager'类都是'Windows.UI.Notifications'命名空间的成员。 – jmcilhinney