//File:Window.xaml.vb Imports System Imports System.Collections.Generic Imports System.Text Imports System.Windows Imports System.Windows.Controls Imports System.Windows.Data Imports System.Windows.Documents Imports System.Windows.Input Imports System.Windows.Media Imports System.Windows.Media.Imaging Imports System.Windows.Shapes Namespace RoutedEvents Public Partial Class MousePosition Inherits System.Windows.Window Public Sub New() InitializeComponent() End Sub Private Sub cmdCapture_Click(sender As Object, e As RoutedEventArgs) Me.[AddHandler](Mouse.LostMouseCaptureEvent, New RoutedEventHandler(AddressOf Me.LostCapture)) Mouse.Capture(rect) cmdCapture.Content = "Mouse captured" End Sub Private Sub MouseMoved(sender As Object, e As MouseEventArgs) Dim pt As Point = e.GetPosition(Me) lblInfo.Text = [String].Format("({0},{1}) in window coordinates", pt.X, pt.Y) End Sub Private Sub LostCapture(sender As Object, e As RoutedEventArgs) lblInfo.Text = "Lost capture" cmdCapture.Content = "Capture the Mouse" End Sub End Class End Namespace