using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Text.RegularExpressions;
using Microsoft.VisualBasic;
namespace HelloWorld
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
string filePathTEST = "";
public MainWindow()
{
InitializeComponent();
// Clearing text event handlers
textBox1.GotFocus += textBox1_GotFocus;
// Enter event handlers for textboxes
textBox1.KeyDown += new System.Windows.Input.KeyEventHandler(textBox1_KeyDown);
}
static void textBox1_KeyDown(object sender, System.Windows.Input.KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
//enter key is down
}
}
The error I am getting when I try to run the above code is the following:
Cannot implicitly convert type 'System.Windows.Forms.KeyEventHandler' to 'System.Windows.Input.KeyEventHandler'
Then I tried changing the code to System.Windows.Input and then I get the following:
Error 1 'System.Windows.Input.KeyEventArgs' does not contain a definition for 'KeyCode' and no extension method 'KeyCode' accepting a first argument of type 'System.Windows.Input.KeyEventArgs' could be found (are you missing a using directive or an assembly reference?)
The whole point of me doing this is that when I press enter on a textbox, I want to take the text in that textbox and populate a certain text file with it but I am not sure how to go about doing that.