/* Handler for selecting a flight * * Removes the handler for the event to make * sure it isn't fired when it shouldn't. Creates * a new Detailed Window passing the selected flight * ID to it. The owner of the new window is the Main * Window, so that it doesn't stay open after the Main * Window is closed. Sets the selected item of the flights * box to none and reapplies the event handler. */ private void SearchResultBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { SearchResultBox.SelectionChanged -= new SelectionChangedEventHandler( this.SearchResultBox_SelectionChanged); /* BEFORE * DetailedWindow dw = new DetailedWindow(flightIDs.ElementAt(SearchResultBox.SelectedIndex), * airlineNames.ElementAt(SearchResultBox.SelectedIndex)); */ DetailedWindow dw = new DetailedWindow(flightIDs.ElementAt(SearchResultBox.SelectedIndex), airlineNames.ElementAt(SearchResultBox.SelectedIndex), SearchArrivalBox.Text, SearchDepartureBox.Text ); dw.Owner = this; dw.Show(); SearchResultBox.SelectedIndex = -1; SearchResultBox.SelectionChanged += new SelectionChangedEventHandler( this.SearchResultBox_SelectionChanged); }