Button mouse down event : Button « 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 » ButtonScreenshots 
Button mouse down event
Button mouse down event
      


<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    x:Class="WpfApplication1.Window1"
    Title="Routed Events" Height="400" Width="800">
  
    <Grid Name="contentGrid" Background="Red">
        <Rectangle Name="clickMeRectangle" 
                   Height="70" 
                   Width="70" 
                   Stroke="Black" 
                   Fill="CadetBlue" />
        <Button Name="clickMeButton" 
                Height="23" 
                HorizontalAlignment="Right" 
                VerticalAlignment="Top" 
                Width="70" 
                MouseDown="Generic_MouseDown" 
                PreviewMouseDown="Generic_MouseDown" 
                Click="clickMeButton_Click">Click Me</Button>
        <TextBlock Name="outputText" />
    </Grid>
</Window>

//File:Window.xaml.vb
Imports System
Imports System.Collections.Generic
Imports System.Linq
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.Navigation
Imports System.Windows.Shapes

Namespace WpfApplication1
  Public Partial Class Window1
    Inherits Window
    Private Sub Generic_MouseDown(sender As Object, e As MouseButtonEventArgs)
      Console.WriteLine(outputText.Text)
      Console.WriteLine(e.RoutedEvent.Name)
      Console.WriteLine(sender.ToString())
      Console.WriteLine(DirectCast(e.Source, FrameworkElement).Name)
    End Sub

    Private Sub Window_MouseUp(sender As Object, e As MouseButtonEventArgs)
      outputText.Text = outputText.Text
    End Sub

    Private Sub clickMeButton_Click(sender As Object, e As RoutedEventArgs)
      outputText.Text = "Button clicked:" + outputText.Text
    End Sub
  End Class
End Namespace

   
    
    
    
    
    
  
Related examples in the same category
1.Rotated ButtonsRotated Buttons
2.Pendulum ButtonPendulum Button
3.Button.Background and DrawingBrushButton.Background and DrawingBrush
4.Button with Semi-Transparent imageButton with Semi-Transparent image
5.Set Width for ButtonSet Width for Button
6.Button HorizontalAlignmentButton HorizontalAlignment
7.Button PaddingButton Padding
8.Button MarginButton Margin
9.Button Padding and HorizontalAlignmentButton Padding and HorizontalAlignment
10.Button HorizontalAlignment: StretchButton HorizontalAlignment: Stretch
11.Set BlurBitmapEffect for ButtonSet BlurBitmapEffect for Button
12.Set Padding for ButtonSet Padding for Button
13.Set Margin for ButtonSet Margin for Button
14.Set Button Content with element valueSet Button Content with element value
15.Set Button Width,Height and Content String by using AttributesSet Button Width,Height and Content String by using Attributes
16.Use Button.Content to set the content for a ButtonUse Button.Content to set the content for a Button
17.Adding image to a ButtonAdding image to a Button
18.Button with no position and sizeButton with no position and size
19.Button with Property AttributesButton with Property Attributes
20.Button with Property ElementsButton with Property Elements
21.Button with default Xml namespaceButton with default Xml namespace
22.Button with named NamespaceButton with named Namespace
23.Button Based On StyleButton Based On Style
24.Property Trigger for ButtonProperty Trigger for Button
25.Setting FontSize for ButtonSetting FontSize for Button
26.Layout Tranform
27.Using alternate elements as the content of a ButtonUsing alternate elements as the content of a Button
28.Button's Background = ImageBrush. The resulting button has an image as its backgroundButton's Background = ImageBrush. The resulting button has an image as its background
29.A rotated ButtonA rotated Button
30.Using Button.Content to set content for ButtonUsing Button.Content to set content for Button
31.Scale TransformScale Transform
32.Scale Transformate a ButtonScale Transformate a Button
33.Fisheye Effect for ButtonFisheye Effect for Button
34.A button that has been skewed and rotatedA button that has been skewed and rotated
35.Button PreviewMouseDown action and MouseDown actionButton PreviewMouseDown action and MouseDown action
36.Button click actionButton click action
37.Add CommandTarget for ButtonAdd CommandTarget for Button
38.Adding graphics to a ButtonAdding graphics to a Button
39.Button with image and text, use grid to layout Button contentButton with image and text, use grid to layout Button content
40.Canvas with Button onCanvas with Button on
41.Resizing ButtonsResizing Buttons
42.To add a button control and a text block to the canvasTo add a button control and a text block to the canvas
43.Resizing ButtonsResizing Buttons
44.To add a button control and a text block to the canvasTo add a button control and a text block to the canvas
45.A simple template for a round buttonA simple template for a round button
46.Load style defined in Xaml and apply to the ButtonLoad style defined in Xaml and apply to the Button
47.Nested Button contentNested Button content
48.Two repeat buttons that increase and decrease a numerical value.Two repeat buttons that increase and decrease a numerical value.
49.Generate Click Events Repeatedly While a Button Is ClickedGenerate Click Events Repeatedly While a Button Is Clicked
50.Button Click event handlerButton Click event handler
51.Button mouse down previewButton mouse down preview
52.Set button properties with Linq styleSet button properties with Linq style
53.Simple Custom ButtonSimple Custom Button
54.Custom Shaped ButtonCustom Shaped Button
55.Raise exception from button click eventRaise exception from button click event
56.Button VerticalAlignment=Top HorizontalAlignment=LeftButton VerticalAlignment=Top  HorizontalAlignment=Left
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.