Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>UPDATE:</p> <p>This is a bit messy, but it might help you after some refactoring. I capture text using the preview event and force sending the Key I want; I ignore all other keys in my preview handler. I did switch from KeyDown to KeyUp to get the preview event to fire first. I use the _clearNext flag to skip/clear the key event.</p> <p>In XAML</p> <pre><code>&lt;Window x:Class="EmployeeNavigator.Views.MainView" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" PreviewTextInput="Window_PreviewTextInput" Keyup="Window_KeyUp" Height="400" Width="600" MinWidth="600"&gt; &lt;/Window&gt; </code></pre> <p>Code-behind detects and processes _</p> <pre><code> private bool _clearNext = false; private void Window_KeyUp(object sender, KeyEventArgs e) { if ( _clearNext ) { _clearNext = false; e.Handled = true; } else if (e.Key == Key.OemMinus) { e.Handled = true; } else if (e.Key == Key.OemQuestion) { e.Handled = true; } } private void Window_PreviewTextInput(object sender, TextCompositionEventArgs e) { if (e.Text.Equals("_")) { KeyEventArgs args = new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.OemMinus); args.RoutedEvent = Keyboard.KeyUpEvent; InputManager.Current.ProcessInput(args); e.Handled = true; _clearNext = true; } else if (e.Text.Equals("?")) { KeyEventArgs args = new KeyEventArgs(Keyboard.PrimaryDevice, Keyboard.PrimaryDevice.ActiveSource, 0, Key.OemQuestion); args.RoutedEvent = Keyboard.KeyUpEvent; InputManager.Current.ProcessInput(args); e.Handled = true; _clearNext = true; } } </code></pre> <p>I'll add there must be a better way.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload