Input Events in WPF using VB.NET: Part 3

In this article you will learn about the all Input Events in WPF.
  • 2069

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.

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.