Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
352 views
in Technique[技术] by (71.8m points)

.net - How do you bind Enter and Esc keys to OK and Cancel buttons respectively in a WPF dialog?

My WPF app uses a dialog with Ok and Cancel buttons. I would like to bind the Enter key to the Ok button and the Esc key to the Cancel button. Seems like it should be a simple thing to do.

question from:https://stackoverflow.com/questions/2031322/how-do-you-bind-enter-and-esc-keys-to-ok-and-cancel-buttons-respectively-in-a-wp

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try setting the IsDefault property on the ok button to true, and the IsCancel property on the cancel button to true.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...