I have my PRISM application set up on a MVP pattern and we display modal windows through custom RegionManager. The problem i face right now is when the users close the Modal Window using an Alt+F4! The View closes but the Cancel button logic is never executed, which is a bug!
So I need to draft a way to invoke the Cancel button of the view when an Alt + F4 is issued.
Having a input key binding for Alt+F4 helps me trap the event in the View. but the problem is invoking the Cancel button of the View, in a easy way. is there any way i could easily find the cancel and Accept buttons in WPF View?
Any help is appreciated. thanks!
Since there a several ways to close a window (Alt+F4, close button, Cancel or Accept buttons), you shouldn't put the closing logic in the code of the buttons, because it will not always be executed. Instead, put your closing logic in the
Closing
orClosed
event. In your Cancel button, just set theDialogResult
to false (true in the Accept button), it will close the window and trigger theClosing
andClosed
events.