Suppress Keyboard and Mouse Events : Key Event « Windows Presentation Foundation « VB.Net






Suppress Keyboard and Mouse Events

Suppress Keyboard and Mouse Events
    

<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="100" Width="200">
    <StackPanel Orientation="Horizontal">
        <StackPanel Orientation="Horizontal" PreviewMouseDown="StackPanel_PreviewMouseDown">
            <Button Content="Blocked" Click="Button_Click" Height="25" Margin="10" Width="70"/>
        </StackPanel>
        <Button Content="Not Blocked" Click="Button_Click" Height="25" Margin="10" Width="70"/>
    </StackPanel>
</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

    Private Sub Button_Click(sender As Object, e As RoutedEventArgs)
      MessageBox.Show("Button Clicked", "Button")
    End Sub

    Private Sub StackPanel_PreviewMouseDown(sender As Object, e As MouseButtonEventArgs)
      e.Handled = True
    End Sub
  End Class
End Namespace

   
    
    
    
  








Related examples in the same category

1.Creating a KeyBinding between the Open command and Ctrl-RCreating a KeyBinding between the Open command and Ctrl-R
2.Command Handler Key BindingCommand Handler Key Binding
3.Use Keyboard.Focus to set the focus to a Text FieldUse Keyboard.Focus to set the focus to a Text Field
4.Provide Quick Keyboard Access to ButtonsProvide Quick Keyboard Access to Buttons
5.Reading keyboard modifiersReading keyboard modifiers
6.Reading individual key state with Keyboard.IsKeyDownReading individual key state with Keyboard.IsKeyDown
7.Use InputBinding to bind Application commends to Key eventsUse InputBinding to bind Application commends to Key events
8.Query Left / Right control keyQuery Left / Right control key
9.Is Key.CapsLock ToggledIs Key.CapsLock Toggled
10.Keyboard.IsKeyToggledKeyboard.IsKeyToggled
11.Query Number lock keyQuery Number lock key
12.Use KeyBinding to bind Key event to TextBox.InputBindingsUse KeyBinding to bind Key event to TextBox.InputBindings
13.Custom Command by KeyGesture and RoutedUICommandCustom Command by KeyGesture and RoutedUICommand
14.TextBox PreviewKeyDown, PreviewKeyUp, PreviewTextInput, KeyDown, KeyUp and TextChanged eventsTextBox PreviewKeyDown, PreviewKeyUp, PreviewTextInput, KeyDown, KeyUp and TextChanged events
15.StackPanel PreviewTextInput and PreviewKeyDownStackPanel PreviewTextInput and PreviewKeyDown
16.If input is not a number do not handle the key eventIf input is not a number do not handle the key event
17.RoutedEvents: Tunneled Key PressRoutedEvents: Tunneled Key Press
18.On Key Down HandlerOn Key Down Handler