private static void OnSelectedBrushPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs args)
        {
            ColorComboBox   ccb      = (ColorComboBox)d;
            SolidColorBrush newBrush = (SolidColorBrush)args.NewValue;

            if (ccb.SelectedColor != newBrush.Color)
            {
                ccb.SelectedColor = newBrush.Color;
            }
        }
        private static void OnSelectedColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs args)
        {
            ColorComboBox ccb = d as ColorComboBox;

            Color newColor = (Color)args.NewValue;
            Color oldColor = (Color)args.OldValue;

            if (newColor == oldColor)
            {
                return;
            }

            // When the SelectedColor changes, set the selected value of the combo box
            ColorItem selectedColorItem = ccb.colorList.SelectedValue as ColorItem;

            if (selectedColorItem == null || selectedColorItem.Color != newColor)
            {
                ColorItem colorItem = ccb.ContainsColor(newColor);

                // Add the color if not found
                if (colorItem == null)
                {
                    if (!ccb._containsCustomColors)
                    {
                        ccb._containsCustomColors = true;
                        ccb.colorList.Items.Add(new Separator());
                    }

                    colorItem = ColorUtilities.GetColorItem(newColor, ColorUtilities.GetHexCode(newColor));
                    ccb.colorList.Items.Add(colorItem);
                }

                ccb.colorList.SelectedValue = colorItem;
            }

            // Also update the brush
            ccb.SelectedBrush = new SolidColorBrush(newColor);
            ccb.OnSelectedColorChanged(oldColor, newColor);
        }