Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

As the question states... I have a dialog with Textboxes that uses enter to trigger an event. Hitting enter within a dialog triggers as if you hit the "primaryButton" and closes the dialog.

Is it possible to disable this functionality without disabling using the enter key all together?

You must be logged in to vote

Replies: 1 comment

Comment options

Yes, you can. In the WindowsDialog.xaml, whatever you named it, add a PreviewKeyDown event, and the function will look like this.

'''
private void WindowsDialog_PreviewKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
// This line prevents the default behavior of the event from occurring.
// It is commonly used to suppress or handle specific input events, such as invalid characters.
e.Handled = true;
}
}
'''

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.