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

Show xaml

5 Answers 129 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Edo Cof
Top achievements
Rank 1
Edo Cof asked on 12 May 2010, 10:52 AM
I am trying to use RichEdit for commenting something.
So the user enter some text, i save it to the base as xaml string (link), but then i want to show it in xaml, and that's the problem.

I write:
            string text = "<t:RadDocument xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" xmlns:t=\"clr-namespace:Telerik.Windows.Documents.Model;assembly=Telerik.Windows.Documents\" ParagraphDefaultSpacingBefore=\"0\" SectionDefaultPageMargin=\"10,10,10,10\" PageViewMargin=\"10,10\" LayoutMode=\"Flow\"><t:Section PageMargin=\"10,10,10,10\"><t:Paragraph SpacingAfter=\"12\"><t:Span Text=\"This is a test.\" FontFamily=\"Verdana\" /></t:Paragraph></t:Section></t:RadDocument>"; 
 
            RadRichTextBox rich = new RadRichTextBox(); 
            rich.Document = XamlReader.Load(text) as <RadDocument>(); 
            xamlPlaceHolder.Child = rich; 
But the user can edit text. I know that i can set read only to true, but the user can still focus RadRichTextBox.

I just want to show text that user enter it when commenting. (with formating of course)

5 Answers, 1 is accepted

Sort by
0
Accepted
Alex
Telerik team
answered on 13 May 2010, 11:34 AM
Hi Edo Cof,

Setting the IsReadOnly property to true will prevent user from modifying the content of the RadRichTextBox. However, the control will still receive focus and will allow the user to select and copy parts of its content.

If you want to stop the control from ever receiving focus, you can try setting the IsEnabled property to false.  

Please let us know if this is what you need or if you need further assistance.

Greetings,
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.
0
Edo Cof
Top achievements
Rank 1
answered on 13 May 2010, 11:44 AM
IsEnabled is a very nice idea. Don't know how i missed it. I will try it and probably it will work.
If user can select text is very good, if not it will be nice to find work arround or add this feature.
(I already post for feature request RichEditViewer)

Now the second thing that bothers me is white background.
I want to show text as plain text (as html) just if i write a textblock.
If i say the other way, how can i remove that white background, so the text background (RadDocument) will be transparent?
0
Accepted
Alex
Telerik team
answered on 14 May 2010, 03:56 PM
Hi Edo Cof,

You can remove the white page background by overriding the default Page template used by the RadRichTextBox. If you want the control to be fully transparent you will have to set the Background property of the RadRichTextBox to Transparent too. Here is an example:

<telerik:RadRichTextBox x:Name="editor" Background="Transparent">
  <telerik:RadRichTextBox.Resources>
    <Style TargetType="docUI:Page">
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="docUI:Page">
            <ContentPresenter x:Name="PageContentPresenter"
                                      Visibility="Collapsed"/>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
      <Setter Property="HorizontalAlignment" Value="Center" />
      <Setter Property="VerticalAlignment" Value="Top" />
    </Style>
  </telerik:RadRichTextBox.Resources>
</telerik:RadRichTextBox>

You will have to add and the following xml namespaces:
xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Documents"
xmlns:docUI="clr-namespace:Telerik.Windows.Documents.UI;assembly=Telerik.Windows.Documents"

Let us know if this was helpful.

Kind regards,
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.
0
Edo Cof
Top achievements
Rank 1
answered on 14 May 2010, 09:03 PM
It seems it works, but i am having problems adding this resources into control template. (So i don't need to add this code every time i want to use that kind of behaviour.

Is this possible?
0
Accepted
Alex
Telerik team
answered on 17 May 2010, 05:35 PM
Hi Edo Cof,

If you want to use this style resource throughout your entire application, you can put it in the App.xaml file. This way you will not need to add it every time you use the RadRichTextBox control.

All the best,
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.
Tags
RichTextBox
Asked by
Edo Cof
Top achievements
Rank 1
Answers by
Alex
Telerik team
Edo Cof
Top achievements
Rank 1
Share this question
or