Handles the MouseDown event on the UniformGrid : UniformGrid « Windows Presentation Foundation « VB.Net Tutorial

Home
VB.Net Tutorial
1.Language Basics
2.Data Type
3.Operator
4.Statements
5.Date Time
6.Class Module
7.Development
8.Collections
9.Generics
10.Attributes
11.Event
12.LINQ
13.Stream File
14.GUI
15.GUI Applications
16.Windows Presentation Foundation
17.2D Graphics
18.I18N Internationlization
19.Reflection
20.Regular Expressions
21.Security
22.Socket Network
23.Thread
24.Windows
25.XML
26.Database ADO.net
27.Design Patterns
VB.Net
VB.Net by API
VB.Net Tutorial » Windows Presentation Foundation » UniformGrid 
16.38.3.Handles the MouseDown event on the UniformGrid
<Window x:Class="WpfApplication1.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="WPF" Height="150" Width="300">
    <UniformGrid Columns="2" Rows="2" ButtonBase.Click="UniformGrid_Click" 
                 MouseDown="UniformGrid_MouseDown">
        <Button Content="Button" MaxHeight="25" MaxWidth="70" Name="Button"/>
        <Label Background="LightBlue" Content="Label" Name="Label"
               HorizontalContentAlignment="Center" 
               MaxHeight="25" MaxWidth="100"/>
        <TextBlock Background="Turquoise" Padding="25,7" Text="TextBlock" 
               HorizontalAlignment="Center" VerticalAlignment="Center"
               Name="TextBlock"/>
        <Canvas MouseDown="Canvas_MouseDown">
            <Rectangle Canvas.Top="15" Canvas.Left="20" Fill="Aqua" 
                Height="25" Width="100" Name="Rectangle"/>
            <TextBlock Canvas.Top="20" Canvas.Left="45" Text="Rectangle" 
                   IsHitTestVisible="False"/>            
        </Canvas>
    </UniformGrid>
</Window>
//File:Window.xaml.vb
Imports System.Windows
Imports System.Windows.Input

Namespace WpfApplication1
  Public Partial Class Window1
    Inherits Window
    Public Sub New()
      InitializeComponent()
    End Sub

    ' Handles the MouseDown event on the Canvas.
    Private Sub Canvas_MouseDown(sender As Object, e As MouseButtonEventArgs)
      Dim fe As FrameworkElement = TryCast(e.OriginalSource, FrameworkElement)

      MessageBox.Show("Mouse Down on " & fe.Name, "Canvas")
    End Sub

    ' Handles the Click event on the UniformGrid.
    Private Sub UniformGrid_Click(sender As Object, e As RoutedEventArgs)
      Dim fe As FrameworkElement = TryCast(e.OriginalSource, FrameworkElement)

      MessageBox.Show("Mouse Click on " & fe.Name, "Uniform Grid")
    End Sub

    ' Handles the MouseDown event on the UniformGrid.
    Private Sub UniformGrid_MouseDown(sender As Object, e As MouseButtonEventArgs)
      Dim fe As FrameworkElement = TryCast(e.OriginalSource, FrameworkElement)

      MessageBox.Show("Mouse Down on " & fe.Name, "Uniform Grid")
    End Sub
  End Class
End Namespace
WPF Handles The Mouse Down Event On The Uniform Grid
16.38.UniformGrid
16.38.1.UniformGrid DemoUniformGrid Demo
16.38.2.Handles the Click event on the UniformGridHandles the Click event on the UniformGrid
16.38.3.Handles the MouseDown event on the UniformGridHandles the MouseDown event on the UniformGrid
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.