Mega Code Archive

 
Categories / VB.Net Tutorial / WPF
 

A line which monitors the mouse entering its area

<Window x: Class="WpfApplication1.MainWindow"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     Title="WpfApplication1" Height="352" Width="334" WindowStartupLocation="CenterScreen">     <StackPanel>       <Line Name ="SimpleLine" X1 ="0" X2 ="50" Y1 ="0" Y2 ="50"              Stroke ="DarkOliveGreen" StrokeThickness ="5"             ToolTip ="This is a line!" MouseEnter ="SimpleLine_MouseEnter"/>     </StackPanel> </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 Namespace WpfApplication1   Public Partial Class MainWindow     Inherits System.Windows.Window     Public Sub New()       InitializeComponent()     End Sub     Protected Sub SimpleLine_MouseEnter(sender As Object, args As MouseEventArgs)       Me.Title = [String].Format("Mouse entered at: {0}", args.GetPosition(SimpleLine))     End Sub   End Class End Namespace