Ignore Alt+F4 in WPF Application

Viewed 17735

How can I ignore Alt+F4 in WPF Application?

3 Answers

Add this to the UIElement/FramworkElement from where you do not wish the Alt+F4 to work.

wnd.KeyDown += new KeyEventHandler(wnd_KeyDown);

void wnd_KeyDown(object sender, KeyEventArgs e)
{
    if ( e.Key == Key.System && e.SystemKey == Key.F4)
    {
        e.Handled = true;
    }
}
Related