src/GenFx.Wpf/Controls/PopulationSelector.xaml.cs
/// <summary>
/// Handles the event when the <see cref="GeneticEnvironment.Populations"/> collection has changed.
/// </summary>
/// <param name="sender">Sender of the event.</param>
/// <param name="e">The <see cref="NotifyCollectionChangedEventArgs"/> associated with the event.</param>
Handles the event when the  collection has changed.
Handles the event when the collection has changed .
private void Populations_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            this.Dispatcher.BeginInvoke(new Action(() =>
            {
                this.TryInitializeSelectedPopulation();
                if (e.Action == NotifyCollectionChangedAction.Remove && e.OldItems.Contains(this.SelectedPopulation))
                {
                    if (this.Environment.Populations.Any())
                    {
                        if (this.SelectedPopulationIndex != 0)
                        {
                            this.SelectedPopulationIndex = 0;
                        }
                        else
                        {
                            this.SelectedPopulation = this.Environment.Populations[this.SelectedPopulationIndex];
                        }
                    }
                    else
                    {
                        this.SelectedPopulationIndex = -1;
                    }
                }
            }));
        }
private void Populations_CollectionChanged ( object sender , NotifyCollectionChangedEventArgs e ) { this . Dispatcher . BeginInvoke ( new Action ( ( ) => { this . TryInitializeSelectedPopulation ( ) ; if ( e . Action == NotifyCollectionChangedAction . Remove && e . OldItems . Contains ( this . SelectedPopulation ) ) { if ( this . Environment . Populations . Any ( ) ) { if ( this . SelectedPopulationIndex != 0 ) { this . SelectedPopulationIndex = 0 ; } else { this . SelectedPopulation = this . Environment . Populations [ this . SelectedPopulationIndex ] ; } } else { this . SelectedPopulationIndex = - 1 ; } } } ) ) ; }
Handles the event when the  collection has changed.
Handles the event when the collection has changed .
// This will implicity set the new selected population // The index hasn't changed but the selected population associated with this index // needs to change now that the collection is changed.
sender
object
Sender of the event.
Sender of the event .
e
NotifyCollectionChangedEventArgs
The  associated with the event.
The associated with the event .