How to capture delete key press in C#?

thuaso picture thuaso · May 23, 2010 · Viewed 51.9k times · Source

I want to capture delete key presses and do nothing when the key is pressed. How can I do that in WPF and Windows Forms?

Answer

Eric picture Eric · Sep 10, 2012

When using MVVM with WPF you can capture keypressed in XAML using Input Bindings.

            <ListView.InputBindings>
                <KeyBinding Command="{Binding COMMANDTORUN}"
                            Key="KEYHERE" />
            </ListView.InputBindings>