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

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » Windows Presentation Foundation » UniformGridScreenshots 
Handles the Click event on the UniformGrid
Handles the Click 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

   
    
    
  
Related examples in the same category
1.UniformGrid DemoUniformGrid Demo
2.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.