private void textBox1_KeyUp(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { dialogresult = true; this.Close(); } } }