private void textBox_KeyDown(object sender, KeyEventArgs e) { string name = textBox.Text; if (string.IsNullOrWhiteSpace(name)) { return; } if (Keyboard.IsKeyDown(Key.Enter)) { if (name[0] == '#') { _ircClient.JoinGroupChat(name); } else { _ircClient.CheckIfUserExists(name); } chatName.Items.Add(name); _chatBoxez.Add(name, showMessages.DeepCopy()); main.Children.Add(_chatBoxez[name]); textBox.Clear(); chatName.SelectedItem = name; FocusManager.SetFocusedElement(main, writeMessages); } }