在弹出消息框期间允许功能快捷键

时间:2015-04-13 10:30:43

标签: c# messagebox

当用户输入的值不正确时,会显示一个消息框,并显示“输入不匹配。是否要覆盖?”。当出现此消息框时,我希望用户能够点击F1键并在显示时显示单独的页面,而不必关闭消息框。这有可能与我的代码方式或我需要重组整个交易?

if (MessageBox.Show("Entry not a match. Do you want to overwrite?", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {   //below is the code I want to use as the shortcut for when the messae box appears if it is possible to do it this way

if (e.Key == Key.F1)
        {
            viewEntry page = new viewEntry ();
            page.textBox.Text = textBox.Text;
            page.ShowDialog();
        }
                    if (MessageBox.Show("Confirm Overwrite", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                    {
                        //do something

                    }
                    tnImage.Text = "✓";
                    tnImage.FontSize = 22;
                    tnImage.Foreground = new SolidColorBrush(Colors.Green);
                    txtTN.BorderBrush = new SolidColorBrush(Colors.Green);
                    txtBN.Focus();
                }
                else
                {
                    return;
                }

0 个答案:

没有答案