internal override void OnSelectedColorChanged(Color?OldValue, Color?NewValue)
        {
            base.OnSelectedColorChanged(NewValue, OldValue);

            // Set color is Updating again
            ColorIsUpdating = true;

            if (PART_ColorPaletteAvailable != null)
            {
                PART_ColorPaletteAvailable.SelectedValue = NewValue;
            }
            if (PART_ColorPaletteStandard != null)
            {
                PART_ColorPaletteStandard.SelectedValue = NewValue;
            }
            if (PART_ColorPaletteCustom01 != null)
            {
                PART_ColorPaletteCustom01.SelectedValue = NewValue;
            }
            if (PART_ColorPaletteCustom02 != null)
            {
                PART_ColorPaletteCustom02.SelectedValue = NewValue;
            }
            if (PART_ColorPaletteRecent != null)
            {
                PART_ColorPaletteRecent.SelectedValue = NewValue;
            }

            if (this.AddToRecentColorsTrigger == AddToRecentColorsTrigger.SelectedColorChanged && SelectedColor.HasValue)
            {
                BuildInColorPalettes.AddColorToRecentColors(NewValue, RecentColorPaletteItemsSource);
                BuildInColorPalettes.ReduceRecentColors(BuildInColorPalettes.GetMaximumRecentColorsCount(this), RecentColorPaletteItemsSource as ObservableCollection <Color?>);
            }

            ColorIsUpdating = false;
        }
        private static void OnIsDropDownOpenChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (d is ColorPicker colorPicker)
            {
                if ((bool)e.NewValue)
                {
                    colorPicker.RaiseEvent(new RoutedEventArgs(DropDownOpenedEvent));

                    colorPicker.Focus();

                    Mouse.Capture(colorPicker, CaptureMode.SubTree);
                    colorPicker.Dispatcher.BeginInvoke(
                        DispatcherPriority.Send,
                        (DispatcherOperationCallback) delegate(object arg)
                    {
                        ColorPicker cp = (ColorPicker)arg;
                        bool isFocused = false;

                        cp.ValidateTabItems();

                        if (cp.PART_PopupTabControl.SelectedItem == cp.PART_ColorPalettesTab)
                        {
                            if (!isFocused && cp.IsStandardColorPaletteVisible && cp.PART_ColorPaletteStandard != null)
                            {
                                isFocused = cp.PART_ColorPaletteStandard.FocusSelectedItem();
                            }
                            else if (!isFocused && cp.IsAvailableColorPaletteVisible && cp.PART_ColorPaletteAvailable != null)
                            {
                                isFocused = cp.PART_ColorPaletteAvailable.FocusSelectedItem();
                            }
                            else if (!isFocused && cp.IsCustomColorPalette01Visible && cp.PART_ColorPaletteCustom01 != null)
                            {
                                isFocused = cp.PART_ColorPaletteCustom01.FocusSelectedItem();
                            }
                            else if (!isFocused && cp.IsCustomColorPalette02Visible && cp.PART_ColorPaletteCustom02 != null)
                            {
                                isFocused = cp.PART_ColorPaletteCustom02.FocusSelectedItem();
                            }
                            else if (!isFocused && cp.IsRecentColorPaletteVisible && cp.PART_ColorPaletteRecent != null)
                            {
                                isFocused = cp.PART_ColorPaletteRecent.FocusSelectedItem();
                            }
                        }
                        else if (cp.PART_PopupTabControl.SelectedItem == cp.PART_AdvancedTab)
                        {
                            cp.PART_AdvancedTab.MoveFocus(new TraversalRequest(FocusNavigationDirection.First));
                        }

                        return(null);
                    }, colorPicker);
                }
                else
                {
                    colorPicker.RaiseEvent(new RoutedEventArgs(DropDownClosedEvent));
                    if (Mouse.Captured == colorPicker)
                    {
                        Mouse.Capture(null);
                    }

                    if (colorPicker.AddToRecentColorsTrigger == AddToRecentColorsTrigger.ColorPickerClosed && colorPicker.SelectedColor.HasValue)
                    {
                        // We Update something so we need to flag this
                        colorPicker.ColorIsUpdating = true;
                        BuildInColorPalettes.AddColorToRecentColors(colorPicker.SelectedColor, colorPicker.RecentColorPaletteItemsSource);
                        BuildInColorPalettes.ReduceRecentColors(BuildInColorPalettes.GetMaximumRecentColorsCount(colorPicker), colorPicker.RecentColorPaletteItemsSource);
                        colorPicker.ColorIsUpdating = false;
                    }
                }
            }
        }