/// <summary>
        /// Handles the event when the <see cref="SelectedPopulationIndex"/> property changes.
        /// </summary>
        /// <param name="obj">The <see cref="DependencyObject"/> that owns the property.</param>
        /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> associated with the event.</param>
        private static void OnSelectedPopulationIndexChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            PopulationSelector selector = (PopulationSelector)obj;

            int index = (int)e.NewValue;

            if (selector.Environment == null || index < 0 || index >= selector.Environment.Populations.Count)
            {
                selector.SelectedPopulation = null;
            }
            else
            {
                selector.SelectedPopulation = selector.Environment.Populations[(int)e.NewValue];
            }
        }
        /// <summary>
        /// Handles the event when the <see cref="Environment"/> property changes.
        /// </summary>
        /// <param name="obj">The <see cref="DependencyObject"/> that owns the property.</param>
        /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> associated with the event.</param>
        private static void OnEnvironmentChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            PopulationSelector selector = (PopulationSelector)obj;

            if (e.OldValue != null)
            {
                GeneticEnvironment environment = (GeneticEnvironment)e.OldValue;
                environment.Populations.CollectionChanged -= selector.Populations_CollectionChanged;
                selector.isSelectedPopulationInitialized   = false;
                selector.SelectedPopulationIndex           = -1;
            }

            if (e.NewValue != null)
            {
                GeneticEnvironment environment = (GeneticEnvironment)e.NewValue;
                environment.Populations.CollectionChanged += selector.Populations_CollectionChanged;
                if (environment.Populations.Any())
                {
                    selector.TryInitializeSelectedPopulation();
                }
            }
        }