Background is always white?

16 posts, 2 answers
  1. Nicolas
    Nicolas avatar
    57 posts
    Member since:
    Dec 2008

    Posted 28 Jul 2010 Link to this post

    Hi,

    I am trying to use the RichTextBox to display rich text, in a read-only way (as described here: http://www.telerik.com/help/silverlight/radrichtextbox-how-to-use-rarichtextbox-as-rich-content-viewer.html). My problem is that I can't get anything but a white background. I would like the background to be transparent (or non-existent). I tried using the new TransparentTheme, and/or setting the background to Nothing but it does not work. Actually setting the background to any color (Background="Red") leaves me with a white background.

    Is this a known issue or am I missing something here?

    Thank you
  2. Answer
    Boby
    Admin
    Boby avatar
    763 posts

    Posted 29 Jul 2010 Link to this post

    Hi Nicolas,
    To make the rich text box background transparent first you will have to set the Background property of the control to transparent. Then you will have to set the Background property in the default style of the presenter you will be using. In case of Flow layout mode this is the DocumentWebLayoutPresenter and in case of Paged layout mode this is the DocumentPrintLayoutPresenter. If you will be using both layout modes you can set both styles.

    Here is how this can be done in XAML:
    <telerik:RadRichTextBox Background="Transparent">
        <telerik:RadRichTextBox.Resources>
            <Style TargetType="telerik:DocumentWebLayoutPresenter">
                <Setter Property="Background" Value="Transparent" />
            </Style>
            <Style TargetType="telerik:DocumentPrintLayoutPresenter">
                <Setter Property="Background" Value="Transparent" />
            </Style>
        </telerik:RadRichTextBox.Resources>
    </telerik:RadRichTextBox>


    Sincerely yours,
    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
  3. Nicolas
    Nicolas avatar
    57 posts
    Member since:
    Dec 2008

    Posted 16 Aug 2010 Link to this post

    Hi Boby,

    thank you for your response.

    I'm creating the control in the code-behind and I'm having trouble implementing this. Could you please give me the equivalent in code-behind (VB preferred) please?

    Thanks
  4. Answer
    Ivailo Karamanolev
    Admin
    Ivailo Karamanolev avatar
    276 posts

    Posted 16 Aug 2010 Link to this post

    Hi Nicolas,

    Here's how to do the equivalent to the previously mentioned XAML in code-behind:
    VB:
    richTextBox.Background = New SolidColorBrush(Colors.Transparent)
    richTextBox.Resources = New ResourceDictionary()
     
    Dim webLayoutStyle As New Style(GetType(DocumentWebLayoutPresenter))
    webLayoutStyle.Setters.Add(New Setter(DocumentWebLayoutPresenter.BackgroundProperty, Colors.Transparent))
    richTextBox.Resources.Add(GetType(DocumentWebLayoutPresenter), webLayoutStyle)
     
    Dim printLayoutStyle As New Style(GetType(DocumentPrintLayoutPresenter))
    printLayoutStyle.Setters.Add(New Setter(DocumentPrintLayoutPresenter.BackgroundProperty, Colors.Transparent))
    richTextBox.Resources.Add(GetType(DocumentPrintLayoutPresenter), printLayoutStyle)
    C#:
    richTextBox.Background = new SolidColorBrush(Colors.Transparent);
    richTextBox.Resources = new ResourceDictionary();
     
    Style webLayoutStyle = new Style(typeof(DocumentWebLayoutPresenter));
    webLayoutStyle.Setters.Add(new Setter(DocumentWebLayoutPresenter.BackgroundProperty, Colors.Transparent));
    richTextBox.Resources.Add(typeof(DocumentWebLayoutPresenter), webLayoutStyle);
     
    Style printLayoutStyle = new Style(typeof(DocumentPrintLayoutPresenter));
    printLayoutStyle.Setters.Add(new Setter(DocumentPrintLayoutPresenter.BackgroundProperty, Colors.Transparent));
    richTextBox.Resources.Add(typeof(DocumentPrintLayoutPresenter), printLayoutStyle);

    I hope this solves your problem. Let us know if you need further assistance.

    Kind regards,
    Ivailo
    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
  5. Nicolas
    Nicolas avatar
    57 posts
    Member since:
    Dec 2008

    Posted 16 Aug 2010 Link to this post

    Hi Ivailo,

    thanks for the details. That worked out perfectly.
  6. Ivailo Karamanolev
    Admin
    Ivailo Karamanolev avatar
    276 posts

    Posted 16 Aug 2010 Link to this post

    Hello Nicolas,

    It's good to hear this solution worked. Let us know if you have any other issues.

    All the best,
    Ivailo
    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
  7. prog1
    prog1 avatar
    61 posts
    Member since:
    Jul 2008

    Posted 17 Sep 2010 Link to this post

    If I use the transparent background, than I can see a white cursor if the textbox is not in focus.
    How to change this to transparent? If I select the text the cursor changes from white to black, which is ok.
  8. prog1
    prog1 avatar
    61 posts
    Member since:
    Jul 2008

    Posted 21 Sep 2010 Link to this post

    Can I change something like the CoursoAlternatingColor to "transparent" with a style, too?
  9. Alex
    Admin
    Alex avatar
    130 posts

    Posted 22 Sep 2010 Link to this post

    Hello prog1,

    We were unable to reproduce the "white cursor" problem - when the rich text box is not focused the caret is not shown. We will appreciate if you elaborate further and send us a sample project through the support system that exhibits the issue so we can investigate it locally.

    Sincerely yours,
    Alex
    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
  10. prog1
    prog1 avatar
    61 posts
    Member since:
    Jul 2008

    Posted 27 Sep 2010 Link to this post

    Tried to reproduce it, but did not get it.
    It's just in my real application.

    Will try to get it later, again.
  11. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 28 Sep 2010 Link to this post

    Hello Fabian,

     We are sorry that we are not able to offer you any solutions to your problem.
    Feel free to get back to us when you reproduce it or if any other issues arise.

    Kind regards,
    Iva
    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
  12. prog1
    prog1 avatar
    61 posts
    Member since:
    Jul 2008

    Posted 26 Jan 2011 Link to this post

    I can reproduce it now.
    Just got to ExpressionBlend, put a RadRichTextbox on a control without background.
    Set the Background of the RadRichTextbox to "null" as well.
    Now you can see the white cursor.

    How can I change this to "null" or transparent, too?
  13. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 28 Jan 2011 Link to this post

    Hello Fabian,

    I am sorry but I am still unable to reproduce the issue.
    Since you have managed to isolate the problem in a simple project, would it be possible that you send it over in a support ticket? In this way we would be able to track down the problem and address it more easily.
    Looking forward to your reply.

    All the best,
    Iva
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  14. prog1
    prog1 avatar
    61 posts
    Member since:
    Jul 2008

    Posted 31 Jan 2011 Link to this post

    After a lot of searching, I finally got the failure.
    There was a wrong style definition, I did not see. So it was not a problem with the telerik control.

    Thanks a lot and sorry it was my fault.
  15. Toby Riley
    Toby Riley avatar
    40 posts
    Member since:
    Aug 2012

    Posted 08 Apr 2011 Link to this post

    Hi,

    I'm tying to set my cursor as white but cannot seem to do this. How did it happen for you?

    Thanks T.
  16. Mike
    Admin
    Mike avatar
    640 posts

    Posted 11 Apr 2011 Link to this post

    Hi Tobias Riley,

    Please find our answer in the following forum thread:
    http://www.telerik.com/community/forums/silverlight/richtextbox/how-to-change-the-cursor-s-color.aspx

    All the best,
    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
Back to Top