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
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"
/>
richTextBox.ChangeTextForeColor(color);
//Text Color
richTextBox.ChangeTextHighlightColor(color);
//Text Background Color
richTextBox.ChangeParagraphBackground(color);
Hope this helps.
Mike
the Telerik team
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"
/>
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
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
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.
Mihail
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
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.
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.
Iva Toteva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>