From c803b726cb5b44d281f7c200d50da8258fb74f41 Mon Sep 17 00:00:00 2001 From: laurencee Date: Sun, 12 Feb 2017 04:04:16 +1000 Subject: [PATCH] Don't clear possible game names before adding new entries Safer drop down open override --- Livestream.Monitor/ViewModels/TopStreamsViewModel.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Livestream.Monitor/ViewModels/TopStreamsViewModel.cs b/Livestream.Monitor/ViewModels/TopStreamsViewModel.cs index 5f4b74e..f596de6 100644 --- a/Livestream.Monitor/ViewModels/TopStreamsViewModel.cs +++ b/Livestream.Monitor/ViewModels/TopStreamsViewModel.cs @@ -223,7 +223,8 @@ public void DropDownOpened(object sender) { var comboBox = sender as ComboBox; if (comboBox?.Text == null) return; - TextBox textBox = (TextBox)(comboBox).Template.FindName("PART_EditableTextBox", (ComboBox)sender); + TextBox textBox = comboBox.Template.FindName("PART_EditableTextBox", comboBox) as TextBox; + if (textBox == null) return; textBox.SelectionStart = comboBox.Text.Length; textBox.SelectionLength = 0; } @@ -351,8 +352,9 @@ private async void UpdatePossibleGameNames() try { var games = await SelectedApiClient.GetKnownGameNames(game); - PossibleGameNames.Clear(); + var oldItems = PossibleGameNames.ToList(); PossibleGameNames.AddRange(games.Select(x => x.GameName)); + PossibleGameNames.RemoveRange(oldItems); ExpandPossibleGames = true; } catch