How do you bind Enter and Esc keys to OK and Cancel buttons respectively in a WPF dialog? August 29, 2023 by Tarik Try setting the IsDefault property on the ok button to true, and the IsCancel property on the cancel button to true.