Color Picker #FF808080 Gray option works differently

1 Answer 179 Views
ColorPicker
BJans
Top achievements
Rank 1
BJans asked on 10 Mar 2022, 10:34 PM

This is a pretty minor issue but the #FF808080 gray appears twice in the default color picker (once at the bottom of first column and once at top of 2nd column) which can lead to a little strangeness.

If you start the color picker with this color selected, it will show both boxes as selected.


The other strangeness I was able to duplicate in the WPF demos (R1 2022SP1) is if I have the 2nd column box gray selected and close the color picker, then when I reopen it the gray at the bottom of the 1st column will be selected.

So start with this:

Click gray at bottom of 1st column, then reopen the screen. The box at the top of the 2nd color will remain selected.

There is a little bit of strangeness too when you have that shade of gray selected and then you click down into one of the "standard colors", it appears to leave the selected border around the original gray color (but does correctly put the selected border around the standard color).


Am I misinterpreting this or is this a bug?

1 Answer, 1 is accepted

Sort by
0
Stenly
Telerik team
answered on 15 Mar 2022, 03:55 PM

Hello Brian,

I was able to reproduce the mentioned behavior on my end as well. As a result of this, I have logged a new bug report in our feedback portal, so, you could vote for it, as well as follow it, to get notified via e-mail when its status gets changed.

In addition, as a token of gratitude for bringing this to our attention, you could find your Telerik points updated.

With that said, as a workaround for this behavior, you could subscribe to the DropDownOpened event of the RadColorPicker control, and modify the default collection, which is bound to the ItemsSource property. The following code snippet shows a sample implementation of this suggestion:

private void RadColorPicker_DropDownOpened(object sender, Telerik.Windows.RadRoutedEventArgs e)
{
    Popup popUp = this.colorPicker.ChildrenOfType<Popup>().FirstOrDefault();
    RadColorPaletteView mainPalette = popUp.Child.ChildrenOfType<RadColorPaletteView>().FirstOrDefault(x => x.Name == "MainPalette");

    var counter = 0;
    var grayColor = "#FF808080";

    for (int i = 0; i < mainPalette.Items.Count; i++)
    {
        Color item = (Color)mainPalette.Items[i];

        if (item.ToString() == grayColor && counter > 0)
        {
            var newColor = new Color();
            newColor = Color.FromRgb(112, 112, 112);

            var itemsSource = mainPalette.ItemsSource as List<Color>;

            itemsSource.RemoveAt(5);
            itemsSource.Insert(5, newColor);
            mainPalette.ItemsSource = null;
            mainPalette.ItemsSource = itemsSource;
        }

        if (item.ToString() == grayColor && counter == 0)
        {
            counter++;
        }
    }
}

With that said, I hope the provided information is of help to you.

Regards,
Stenly
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
ColorPicker
Asked by
BJans
Top achievements
Rank 1
Answers by
Stenly
Telerik team
Share this question
or