Mega Code Archive

 
Categories / VB.Net Tutorial / WPF
 

Check the mouse event source

<Window x: Class="WpfApplication1.Window1"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     Title="MouseInput" Height="300" Width="300">     <Grid>       <Ellipse Fill="Blue" x:Name="myEllipse" />     </Grid> </Window> //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 Imports System.Diagnostics Namespace WpfApplication1   Public Partial Class Window1     Inherits System.Windows.Window     Public Sub New()       InitializeComponent()     End Sub     Private Sub StartSlowWork()       Mouse.OverrideCursor = Cursors.AppStarting     End Sub     Private Sub SlowWorkCompleted()       Mouse.OverrideCursor = Nothing     End Sub     Protected Overrides Sub OnMouseDown(e As MouseButtonEventArgs)       MyBase.OnMouseDown(e)       If e.Source Is myEllipse Then         StartSlowWork()       End If     End Sub     Protected Overrides Sub OnMouseUp(e As MouseButtonEventArgs)       MyBase.OnMouseUp(e)       SlowWorkCompleted()     End Sub   End Class End Namespace