#315 – Setting IsDefault and IsCancel to the Same Button

You normally set either the IsDefault or IsCancel properties on a button, depending on its purpose.  But you can also set both properties to true for the same button.  You’d typically do this on a dialog that only has one button for closing the dialog.  In this case, you’d want the button to activate when the user pressed either ENTER or ESC (Escape).

	            <Button Content="OK" Width="100" Margin="15"
	                    IsDefault="True" IsCancel="True"
	                    Click="OK_Click"/>

Advertisements