ARTICLE

Input Events in WPF: Part 3

Posted by Manish Tewatia Articles | WPF using VB.NET September 02, 2010
In this article you will learn about the all Input Events in WPF.
 
Reader Level:

As I have already explained in my last article WPF involves so many event but here I will explain about the Input Event of the WPF. As input word implies some parameter which woks for the system or application as a input on the basis of parameter system or application will respond and event stands for the action like whenever you click on a button or type some text into a form in your browser, you are using events.

The Input Events divided into three categories Keyboard events, Mouse events, Stylus events. This part of article explain about the Stylus events.

Stylus Events:

A Stylus is the pen-like device used by Tablet PCs--acts like a mouse by default. In other words, its use raises events such as MouseMove, MouseDown, and MouseUp. This behavior is essential for a stylus to be usable with programs that aren't designed specifically for a Tablet PC. However, if you want to provide an experience that is optimized for a stylus, you can handle stylus-specific events such as StylusMove, StylusDown, and StylusUp. A stylus can do more "tricks" than a mouse, as evidenced by some of its events that have no mouse counterpart, such as StylusInAirMove,
StylusSystemGesture, StylusInRange, and StylusOutOfRange. There are other ways to exploit a stylus without handling these events directly, however. The next chapter, "Introducing WPF's Controls," shows how this can be done with a powerful InkCanvas element.

Example of the Stylus Event

Xaml Code

<Window x:Class="AboutDialog"  MouseRightButtonDown= "AboutDialog_MouseRightButtonDown"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="ABOUT DEVELOPMENT" SizeToContent="WidthAndHeight"
        Background
="Blue">
    <StackPanel>
        <Label FontWeight="Bold" FontSize="20" Foreground="White">
            DEVELOPMENT BOOKS
       
</Label>
        <Label>BOOK FOR STUDENTS</Label>
        <Label>LIST OF BOOKS:</Label>
        <ListBox>
            <ListBoxItem>BOOK 1</ListBoxItem>
            <ListBoxItem>BOOK 2</ListBoxItem>
            <ListBoxItem>BOOK 3</ListBoxItem>
        </ListBox>
        <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
            <Button MinWidth="75" Margin="10">Help</Button>
            <Button MinWidth="75" Margin="10">OK</Button>
        </StackPanel> 
    </StackPanel>
</
Window>

Vb Code

Imports
System.Windows
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Controls 
Partial Public Class AboutDialog
    Inherits Window
    Public Sub New()
        InitializeComponent()
    End Sub
    Private Sub AboutDialog_MouseRightButtonDown(ByVal sender As Object, ByVal e As MouseButtonEventArgs)
        ' Display information about this event 
        ' In this example, all possible sources derive from Control
        Dim source As Control = TryCast(e.Source, Control
        ' Toggle the border on the source control
        If source.BorderThickness <> New Thickness(5) Then
            source.BorderThickness = New Thickness(5)
            source.BorderBrush = Brushes.Black
        Else
            source.BorderThickness = New Thickness(0)
        End If
    End
Sub
End Class

Output Window

stylus1.gif

Conclusion

Hope this article helps you to understand the Input Events in WPF.

share this article :
post comment
 
Nevron Diagram
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
    Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor