private void RefreshWindowList(object sender, RoutedEventArgs e) { var selectedNew = Model.SelectedWindow; var selected = default(WindowItem); Model.RefreshWindowList(); if (selectedNew != null) { selected = Model.Windows.FirstOrDefault(x => x.WindowHandle == selectedNew.WindowHandle); } var hwnd = ((HwndSource)HwndSource.FromVisual(this)).Handle; Model.SelectedWindow = selected ?? Model.Windows.FirstOrDefault(x => x.WindowHandle == hwnd); if (Model.SelectedWindow != null) { WindowList.ScrollIntoView(WindowList.Items[WindowList.Items.Count - 1]); WindowList.ScrollIntoView(Model.SelectedWindow); } }