Set the ok and cancel buttons by default

I have a WPF application written in C #. This application has dialogs in it. Each of these dialogs has a Save and Cancel button. When the user presses "Enter" on the keyboard, I want to automatically "press" the "Save" button. When the user presses "Esc" on his keyboard, I want to simulate a click on the "Cancel" button. Is there an easy way to do this in WPF?

Thank!

+5
source share
1 answer

This button has the following properties: IsDefaultandIsCancel

Set the appropriate values ​​on the corresponding buttons.

+15

All Articles