Close a window with Escape key pressed : Window « 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 » WindowScreenshots 
Close a window with Escape key pressed
Close a window with Escape key pressed
     

<Window x:Class="_360Timer.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Concentric Rings" Width="910" Height="512">
  <Canvas Name="MainCanvas" Background="#FFE0E0E0"/>
</Window>
//File:Window.xaml.vb


Imports System
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Media
Imports System.Windows.Shapes
Imports System.Windows.Media.Animation


Namespace _360Timer

  Public Partial Class Window1
    Inherits Window
    Public Sub New()
      InitializeComponent()

      Me.Show()

      AddHandler Me.KeyDown, New System.Windows.Input.KeyEventHandler(AddressOf Window1_KeyDown)
    End Sub

    Private Sub Window1_KeyDown(sender As Object, e As System.Windows.Input.KeyEventArgs)
      If e.Key = System.Windows.Input.Key.Escape Then
        Me.Close()
      End If
    End Sub

  End Class
End Namespace

   
    
    
    
    
  
Related examples in the same category
1.Custom Window
2.Set window size in XAMLSet window size in XAML
3.A simple user-login XAML pageA simple user-login XAML page
4.User login screen with no layout or formattingUser login screen with no layout or formatting
5.Automatically Size the Main Application Window to Accommodate Its ContentAutomatically Size the Main Application Window to Accommodate Its Content
6.Window.CommandBindingsWindow.CommandBindings
7.Window OwnershipWindow Ownership
8.Window.DragMoveWindow.DragMove
9.Window Closing and Closed eventWindow Closing and Closed event
10.Creating the main panel and add to Window in CodeCreating the main panel and add to Window in Code
11.Change window cursorChange window cursor
12.Show window based on button nameShow window based on button name
13.Listen to Window loaded eventListen to Window loaded event
14.Create Window and add window closing event handlerCreate Window and add window closing event handler
15.Activate window, close window, bring window to frontActivate window, close window, bring window to front
16.Set a Default ButtonSet a Default Button
17.Non-Rectangular windowNon-Rectangular window
18.Window Preview Key EventsWindow Preview Key Events
19.Window with Menu, ToolBar, StatusBarWindow with Menu, ToolBar, StatusBar
20.Order of precedence for sizing-related properties that are implemented by Window.Order of precedence for sizing-related properties that are implemented by Window.
21.Use Window Activated and Deactivated event to control a media fileUse Window Activated and Deactivated event to control a media file
22.Transparent WindowTransparent Window
23.Animated Video WindowAnimated Video Window
24.Use WindowState to make full screen window, change resize mode to NoReSize
25.Do not handle events until Window is fully initialized.Do not handle events until Window is fully initialized.
26.Window On Mouse move eventWindow On Mouse move event
27.Window On Mouse up eventWindow On Mouse up event
28.Window mouse down eventWindow mouse down event
29.Window Preview mouse down eventWindow Preview mouse down event
30.Window mouse up eventWindow mouse up event
31.Load resource from Window ResourcesLoad resource from Window Resources
32.Launch a window with defined XAMLLaunch a window with defined XAML
33.Create a non-rectangular windowCreate a non-rectangular window
34.Display window as dialogDisplay window as dialog
35.Windows Transparent BackgroundWindows Transparent Background
36.Save Window Position to RegistrySave Window Position to Registry
37.Center a Window to ScreenCenter a Window to Screen
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.