This is a migrated thread and some comments may be shown as answers.

Is a custom color picker possible?

5 Answers 23 Views
ColorPicker
This is a migrated thread and some comments may be shown as answers.
Psyduck
Top achievements
Rank 4
Bronze
Bronze
Iron
Psyduck asked on 02 Apr 2021, 12:45 PM

Hello.

 

First of all, please check the image.

My question is this.

1. The textbox in the splitbutton has no function. Can the ColorPicker be displayed in the same way as the arrow function?

    Arrow button down when clicking text box.

 

 

2. Can I change the location of Themes colors and Standard Colors?

     MainPalette and StandardPalette properties exist, but cannot be reversed.

 

 

 

Is there a solution?

Thanks.

5 Answers, 1 is accepted

Sort by
1
Dilyan Traykov
Telerik team
answered on 05 Apr 2021, 02:13 PM

Hello,

Thank you for the provided image.

To achieve the desired result, you can use the ColorSelectorStyle and SplitButtonStyle properties of the RadColorPicker control.

In the style for the RadColorSelector, you can change the values of the Grid.Row property of the elements displaying the MainPalette and StandardPalette to achieve the desired order.

As for enabling the click of the button part of the RadSplitButton, you can create an attach behavior in which you can handle the Checked and Unchecked events. For the purpose, you will also need to set its IsToggle property to true.

For your convenience, I've prepared a small sample project which demonstrates both modifications. Please have a look and let me know if this provides the desired result.

Regards,
Dilyan Traykov
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/.

0
Psyduck
Top achievements
Rank 4
Bronze
Bronze
Iron
answered on 06 Apr 2021, 12:56 AM

Hi.

 

Thanks for helping me.

This works perfectly and is what I want.

 

I have a question.

If I want to change the palette position, do I have to change it only in BaseStyle?

It seems like overwriting an existing Style and it looks complicated, so I just ask.

 

And I posted a post, but you don't need to answer the behavior part of the split button.

Thank you.

1
Dilyan Traykov
Telerik team
answered on 06 Apr 2021, 09:56 AM

Hi KIM,

Actually, you can also achieve the same result in code behind by adding an extra handler to the custom behavior I created:

        private static void Button_Loaded(object sender, RoutedEventArgs e)
        {
            var splitButton = sender as RadSplitButton;
            var colorSelector = splitButton.DropDownContent as RadColorSelector;
            colorSelector.Loaded += (s, a) =>
            {
                var rootElement = colorSelector.ChildrenOfType<Grid>().First(x => x.Name == "RootElement");
                Grid.SetRow(rootElement.Children[1], 4);
                Grid.SetRow(rootElement.Children[2], 5);
                Grid.SetRow(rootElement.Children[3], 6);
                Grid.SetRow(rootElement.Children[4], 1);
                Grid.SetRow(rootElement.Children[5], 2);
                Grid.SetRow(rootElement.Children[6], 3);
            };
        }

For your convenience, I'm also attaching the updated project with these modifications.

Please have a look and let me know if this is what you had in mind.

Regards,
Dilyan Traykov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Psyduck
Top achievements
Rank 4
Bronze
Bronze
Iron
answered on 07 Apr 2021, 04:52 AM

Hello.

Thanks, it works well. That's what I want.

Does this really have no effect on performance? between xaml and loaded?

1
Dilyan Traykov
Telerik team
answered on 07 Apr 2021, 01:47 PM

Hello KIM,

I'm happy to hear that you managed to achieve the desired result.

I'm not absolutely certain, but I believe using the code-behind approach would be a bit quicker than overriding the default template. To be completely sure, you can profile the application with both approaches and decide for yourself. Nonetheless, I do believe the difference in performance is negligible.

Regards,
Dilyan Traykov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
ColorPicker
Asked by
Psyduck
Top achievements
Rank 4
Bronze
Bronze
Iron
Answers by
Dilyan Traykov
Telerik team
Psyduck
Top achievements
Rank 4
Bronze
Bronze
Iron
Share this question
or