private void OK_Click(object sender, RoutedEventArgs e) { newList = new Playlist(NameBox.Text); foreach (KeyValuePair <String, Game> selected in SelectedGames.SelectedItems) { newList.AddGame(selected.Key); } this.Close(); }