Alex Rivera | Logout

Ignore Alt+F4 in WPF Application

Asked 2010-08-31T15:58:32.830
22

How can I ignore Alt+F4 in WPF Application?

Edit
Report

1 Answer

49

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;
    }
}
answered 2011-01-20T22:11:31.687

Your Answer