Hello all,
I have developed a class based off of the Popup class in the Primitives namespace. Basically, this popup is designed to mimic a ToolTip, but can be shown at will by setting its IsOpen property (in this case, it is being used to notify the user when an invalid
entry takes place in a TextBox/PasswordBox)
Here is my control:
Namespace Classes.Controls
Public Class ToolTipPopup
Inherits Primitives.Popup
#Region " Storage "
Private WithEvents tmrClose As New Forms.Timer
#End Region
#Region " Properties "
'Gets or sets the text of the ToolTipPopup class
Private propertyTip As String = Nothing
''' <summary>
''' Gets or sets the text of the ToolTipPopup class.
''' </summary>
Public Property Tip As String
Get
Return propertyTip
End Get
Set(value As String)
propertyTip = value
End Set
End Property
#End Region
#Region " Constructor "
Public Sub New(ByVal tip As String)
With Me
.Tip = tip
End With
With tmrClose
.Interval = 5000
End With
End Sub
Public Sub New(ByVal tip As String, ByVal duration As Integer)
With Me
.Tip = tip
End With
With tmrClose
.Interval = duration
End With
End Sub
#End Region
#Region " Event Handlers "
#Region " ToolTipPopup "
#Region " [Class Definition] "
Private Sub ToolTipPopup_Initialized(sender As Object, e As EventArgs) Handles Me.Initialized
Dim brdrToolTip As New Border
Dim tbToolTip As New TextBlock
With brdrToolTip
.Background = Brushes.White
.BorderBrush = CType(Application.configWindow.FindResource("Accent"), SolidColorBrush)
.BorderThickness = New Thickness(1)
.Child = tbToolTip
.Padding = New Thickness(5, 1, 5, 4)
.SnapsToDevicePixels = True
End With
With tbToolTip
.FontFamily = New FontFamily("Segoe UI")
.FontSize = 13
.Foreground = New SolidColorBrush(Color.FromArgb(255, 51, 51, 51))
.Padding = New Thickness(0)
.Text = Tip
End With
With Me
.AllowsTransparency = True
.Child = brdrToolTip
.Placement = Primitives.PlacementMode.Mouse
.PopupAnimation = Primitives.PopupAnimation.Fade
.StaysOpen = False
End With
End Sub
Private Sub ToolTipPopup_Opened(sender As Object, e As EventArgs) Handles Me.Opened
tmrClose.Start()
End Sub
#End Region
#End Region
#Region " Timer "
#Region " tmrClose "
Private Sub tmrClose_Tick(sender As Object, e As EventArgs) Handles tmrClose.Tick
Me.IsOpen = False
tmrClose.Stop()
End Sub
#End Region
#End Region
#End Region
End Class
End NamespaceI am having issues however, with the PopupAnimation. It seems to only work after the IsOpen property is changed to True, the second time and thereafter. In other words, the animation does not work when being opened the first time.
If anyone knows a solution to this issue, any input would be appreciated.
Thanks,
- Jake M.