Class Window1
Dim sp As StackPanel
Dim tb As TextBlock
Dim p As New Point
Private Sub Window1_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
sp = New StackPanel
tb = New TextBlock
tb.Text = "Some String here"
tb.Background = Brushes.AliceBlue
tb.HorizontalAlignment = Windows.HorizontalAlignment.Center
tb.VerticalAlignment = Windows.VerticalAlignment.Center
sp.Children.Add(tb)
Me.Content = sp
End Sub
Protected Overrides Sub OnMouseMove(ByVal e As System.Windows.Input.MouseEventArgs)
MyBase.OnMouseMove(e)
If e.LeftButton = MouseButtonState.Pressed Then
Me.Title = e.GetPosition(sp).X & "," & e.GetPosition(sp).Y
If (e.GetPosition(sp).X - p.X) > 30 Then
tb.FontSize += 2
p = e.GetPosition(sp)
ElseIf (e.GetPosition(sp).X - p.X) < -30 Then
If tb.FontSize > 8 Then
tb.FontSize -= 2
End If
p = e.GetPosition(sp)
End If
End If
End Sub
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Input.MouseButtonEventArgs)
MyBase.OnMouseDown(e)
p = e.GetPosition(sp)
Me.CaptureMouse()
End Sub
Protected Overrides Sub OnMouseUp(ByVal e As System.Windows.Input.MouseButtonEventArgs)
MyBase.OnMouseUp(e)
ReleaseMouseCapture()
End SubEnd Class