Custom ColorPicker in RichTextBox

8 posts, 0 answers
  1. FU
    FU avatar
    24 posts
    Member since:
    Jul 2006

    Posted 08 Jun 2011 Link to this post

    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?
  2. Mike
    Admin
    Mike avatar
    640 posts

    Posted 14 Jun 2011 Link to this post

    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
  3. DevCraft banner
  4. FU
    FU avatar
    24 posts
    Member since:
    Jul 2006

    Posted 15 Jun 2011 Link to this post

    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" />
  5. Boby
    Admin
    Boby avatar
    595 posts

    Posted 17 Jun 2011 Link to this post

    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
  6. Nick Wood
    Nick Wood avatar
    126 posts
    Member since:
    Feb 2010

    Posted 20 May 2012 Link to this post

    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
  7. Mihail
    Admin
    Mihail avatar
    192 posts

    Posted 23 May 2012 Link to this post

    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 >>

  8. Nick Wood
    Nick Wood avatar
    126 posts
    Member since:
    Feb 2010

    Posted 25 May 2012 Link to this post

    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.
  9. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 29 May 2012 Link to this post

    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 >>

Back to Top
DevCraft banner