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

Custom ColorPicker in RichTextBox

7 Answers 176 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
FU
Top achievements
Rank 2
FU asked on 08 Jun 2011, 01:26 PM
Hi

I'm trying to setup a custom ColorPicker in a RichTextBox for selection fontcolor. I've essentialliy copied a custom ColorPicker from your examples (Color Selector) as a UserControl.

How do I replace the builtin default ColorPicker in the RadRichTextRibbonUI in the RichTextBox?
How do i return the selected value from my custom ColorPicker to the RichTextBox?

7 Answers, 1 is accepted

Sort by
0
Mike
Telerik team
answered on 14 Jun 2011, 07:42 AM
Hi FU,

If you are using the xaml code generated by RadRichTextBoxRibbonUI by default the ColorPicker declarations should look similar to the following:

<telerik:HighlightColorPicker AutomaticColor="Transparent" Height="22" Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/highlight.png" NoColorText="No color" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeFontHighlightColorCommand}" SelectedColor="Yellow" />
                            <telerik:HighlightColorPicker Height="22" Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/FontForeColor.png" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeFontForeColorCommand}" SelectedColor="Red" />
You can replace these with your own color picker. In order to actually change colors your color pickers should call one of the corresponding methods:
richTextBox.ChangeTextForeColor(color); //Text Color
richTextBox.ChangeTextHighlightColor(color); //Text Background Color
richTextBox.ChangeParagraphBackground(color);

Hope this helps.


Kind regards,
Mike
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
FU
Top achievements
Rank 2
answered on 15 Jun 2011, 09:03 AM
Thanks for your help.

I'm very new at Silverlight and so the syntax isn't quite clear yet. How would I change this line to instantiate my usercontrol myCustomColorPicker:
<telerik:HighlightColorPicker Height="22" Image="/Telerik.Windows.Controls.RichTextBoxUI;component/Images/MSOffice/16/FontForeColor.png" telerik:RadRichTextBoxRibbonUI.RichTextCommand="{Binding Path=ChangeFontForeColorCommand}" SelectedColor="Red" />

I¨ve added this line to include myCustomColorPicker:

<fu:myCustomColorPicker x:Name="myNewColorPicker" Visibility="Collapsed" />
0
Boby
Telerik team
answered on 17 Jun 2011, 02:51 PM
Hi Claus,

If you want to use your custom color picker, you just have to replace the code lines pointed out by Mike with your one. Configuring your custom control depends on its implementation, but setting Visibility to Collapsed will most probably make it invisible.

Don't hesitate to contact us if you have other questions.

Regards,
Boby
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Nick Wood
Top achievements
Rank 1
answered on 20 May 2012, 01:05 PM
Hi There

richTextBox.ChangeParagraphBackground(color); does not work in the latest build, I am using both:
richTextBox.ChangeTextForeColor(color);
richTextBox.ChangeTextHighlightColor(color);
These 2 methods work.

Nick
0
Mihail
Telerik team
answered on 23 May 2012, 12:44 PM
Hello Nick,

All of the methods you mention use the caret position in order to determine the place in the document the changes must made. This means that the changes will be applied to the paragraph/span in which the caret is placed.

Please, give us some more information about your scenario, if this information doesn't help you as we couldn't reproduce the described problem.
 

All the best,
Mihail
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Nick Wood
Top achievements
Rank 1
answered on 26 May 2012, 01:41 AM
I am doing nothing different with the carat position from these 2 methods:
richTextBox.ChangeTextForeColor(color);
richTextBox.ChangeTextHighlightColor(color);
Both of these work, but:
richTextBox.ChangeParagraphBackground(color); Does not work.

Why would the first 2 methods work perfectly but the last not work when they are all implemented in exactly the same way.
0
Iva Toteva
Telerik team
answered on 29 May 2012, 04:37 PM
Hi Nick,

As Mihail said, we are not able to reproduce the issue on our end. Please find attached my test application.

If you manage to reproduce the behavior with the demo, we would appreciate it if you could list the steps which we should follow. Provided that the demo works correctly on your end, but you are not able to resolve the issue in your original application, you should attach a project of yours illustrating the incorrect behavior using the support ticketing system.

In any case, please include information on the version of the controls you are using.

Regards,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
RichTextBox
Asked by
FU
Top achievements
Rank 2
Answers by
Mike
Telerik team
FU
Top achievements
Rank 2
Boby
Telerik team
Nick Wood
Top achievements
Rank 1
Mihail
Telerik team
Iva Toteva
Telerik team
Share this question
or