我想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