1

I have a listview for show all users.

I want to search this with KeyDown.

<i:EventTrigger EventName="KeyDown" >
        <cmd:EventToCommand Command="{Binding SearchCommand}"
            PassEventArgsToCommand="True" />
</i:EventTrigger>

and in ViewModel

new RelayCommand<KeyEventArgs>(e =>
{
    e.Key
});

I use persian language and pree 'س', but e.Key have 's'

How to get persian char for serach in listview?

daniele3004
  • 13,072
  • 12
  • 67
  • 75
ar.gorgin
  • 4,765
  • 12
  • 61
  • 100
  • possible duplicate of [How to convert a character in to equivalent System.Windows.Input.Key Enum value?](http://stackoverflow.com/questions/544141/how-to-convert-a-character-in-to-equivalent-system-windows-input-key-enum-value) – dav_i Dec 02 '14 at 09:11
  • 2
    Use the TextInput event instead. – Hans Passant Dec 02 '14 at 09:12
  • @HansPassant : Thanks but don't raise TextInput when press a key. – ar.gorgin Dec 02 '14 at 09:23
  • @dav_i : Thanks, but how to do use this for get persian char of key? – ar.gorgin Dec 02 '14 at 09:24
  • 1
    Hans Passant's *approach* is nonetheless the approach you should be taking, even if the details aren't necessarily entirely correct (I can't tell): if you're not interested in what key is pressed, but rather what character that key translates to, that is *very* difficult to obtain reliably from the key info. Does the `PreviewTextInput` perhaps get raised? –  Dec 02 '14 at 10:01
  • I want to search in listview when i press a key like search a file in windows(search with first char).my problem is : i get same Key for Keydown when change QWERTY layout. – ar.gorgin Dec 02 '14 at 10:02
  • Yes, the same key can sometimes produce `s` with one keyboard layout, and sometimes produce `س` with a different keyboard layout, but it's still the same key. Windows Explorer almost certainly won't be using its equivalent of the `KeyDown` event (the `WM_KEYDOWN` message) for that either. –  Dec 02 '14 at 10:07
  • @hvd : Thanks a lot, i use `PreviewTextInput` for get pressed char :) – ar.gorgin Dec 02 '14 at 10:09
  • I'll give Hans Passant a first chance to write it up as an answer, if he wishes, otherwise I'll try to post it as an answer with some more background information later. :) –  Dec 02 '14 at 10:15

0 Answers0