Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Tuesday, February 5, 2019 5:54 PM
Hi,
I am trying to have the toast notification working in a desktop program (Windows Forms App) I have done in VB.NET VS2013 on a Windows 7 machine.
I now am using VS 2017 on a Windows 10 machine.
Searching through the web I was able to find an example (can't recall the author though) and have it working using a UWP project, but when I use the code in my Windows Forms App, it does not want to work. I get the following error: "error BC30652: Reference required to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken....."
I have tried to find out how I can add that reference but can't figure it out ...
The error disappear when I comment the line : MyToast.ExpirationTime = DateTime.Now.AddSeconds(4)
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Try
Dim MySbXML As New StringBuilder()
MySbXML.Append("<toast><visual><binding template = ""ToastImageAndText01""><text id = ""1"" >")
MySbXML.Append("My Title" & vbCrLf & "My text here")
MySbXML.Append("</text></binding></visual></toast>")
Dim MyXmlDoc As New Windows.Data.Xml.Dom.XmlDocument()
MyXmlDoc.LoadXml(MySbXML.ToString())
Dim MyToast = New ToastNotification(MyXmlDoc)
'MyToast.ExpirationTime = DateTime.Now.AddSeconds(4)
Dim MyNotifier As ToastNotifier = ToastNotificationManager.CreateToastNotifier
MyNotifier.Show(MyToast)
Catch ex As Exception
MsgBox(ex.StackTrace & vbNewLine & ex.Message)
End Try
End Sub
Any idea ... or anyone with an example of working Toast Notification in VB.NET Windows Forms App ... would like to use that feature but don't want to redo the program for it :)
All replies (3)
Tuesday, February 5, 2019 10:51 PM
Hello,
I would recommend look at the following notification/toast window that is installed via NuGet.
https://www.nuget.org/packages/Tulpep.NotificationWindow.
Sample code using random colors and timeout.
Imports Tulpep.NotificationWindow
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim popupNotifier1 = New PopupNotifier
popupNotifier1.ContentText = "Server(s) loaded"
popupNotifier1.BodyColor = Color.DeepSkyBlue
popupNotifier1.ContentPadding = New Padding(12)
popupNotifier1.Delay = 2000
popupNotifier1.ButtonBorderColor = Color.DeepSkyBlue
popupNotifier1.Popup()
End Sub
End Class
Imports Tulpep.NotificationWindow
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim popupNotifier1 = New PopupNotifier
popupNotifier1.ContentText = "Server(s) loaded"
popupNotifier1.BodyColor = Color.DeepSkyBlue
popupNotifier1.ContentPadding = New Padding(12)
popupNotifier1.Delay = 20000
popupNotifier1.BorderColor = Color.Red
popupNotifier1.HeaderColor = Color.Red
popupNotifier1.GradientPower = 10
popupNotifier1.Popup()
End Sub
End Class
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
VB Forums - moderator
Wednesday, February 6, 2019 3:32 PM
Thanks Karen,
I tried the propose NuGet and it's an elegant solution and will keep it in note. I did one personal notification popup using a form and a fade in - fade out effect (not as fancy as the NuGet one though), but I am really trying to acheive is to make it through Windows Notifications.
I am partially able to acheive my goal using a simple NotifyIcon Balloon popup.
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
NotifyIcon1.BalloonTipTitle = "This is a title"
NotifyIcon1.BalloonTipText = "This is some text ..." & vbCrLf & "and some more text here :)"
NotifyIcon1.ShowBalloonTip(3000)
End Sub
This will give the folowing result:
And it even goes in the Action Center and shows a Notification indicator in the taskbar:
there is more that can be done with the notifications ... and that's what I am looking for.
Wednesday, February 6, 2019 6:49 PM
In that case UWP apps are the direction to follow.
Most code samples are in C#.
Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
VB Forums - moderator