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

Default Line Spacing

4 Answers 269 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
tj
Top achievements
Rank 1
tj asked on 19 Oct 2010, 10:02 AM
Hi,

When I create the richtextbox editor, the default line spacing is single. But when I bind it to my viewmodel, the default line spacing is set to multiple. Can I set the default line space to just single?

thanks,
tj

4 Answers, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 20 Oct 2010, 05:38 PM
Hello tj,

When binding RadRichTextBox through a format provider, the format provider actually instantiates a new RadDocument and sets the Document property of the RadRichTextBox to the newly created document. Therefore, your custom settings do not apply.
What you can do is catch the SetupDocument event of the provider, which occurs after setting the content of the document but before visualizing it on the page, and handle it as you like. Some help on this is available here.
In your case, you would need something like:
private void HtmlDataProvider_SetupDocument(object sender, Telerik.Windows.Documents.FormatProviders.SetupDocumentEventArgs e)
        {
            e.Document.LineSpacing = 1.15;
        }
 

Sincerely yours,
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
0
Jonathon
Top achievements
Rank 1
answered on 08 Sep 2011, 01:19 AM
Hi,

The link you posted gives an error.

I am binding a RadRichTextBox to Txt:TxtDataProvider and want to set the default Paragraph SpacingAfter to 0. I already tried doing this:

<Txt:TxtDataProvider   RichTextBox="{Binding ElementName=description}"
                                    Text="{Binding Description, Mode=TwoWay}" />
<telerik:RadRichTextBox  x:Name="description" DocumentInheritsDefaultStyleSettings="True" >
                <telerik:RadRichTextBox.Document>
                    <telerik:RadDocument>
                        <telerik:Section>
                            <telerik:Paragraph SpacingAfter="0" />
                        </telerik:Section>
                    </telerik:RadDocument>
                </telerik:RadRichTextBox.Document>
            </telerik:RadRichTextBox>

But from what you wrote, it won't work. Any other links?

Thanks,

Jonathon
0
Iva Toteva
Telerik team
answered on 08 Sep 2011, 06:51 PM
Hi Jonathon,

I am sorry, this is the correct link: http://www.telerik.com/help/silverlight/radrichtextbox-features-data-providers.html.
Here is also a code-snippet, which should be what you need:

<Txt:TxtDataProvider RichTextBox="{Binding ElementName=description}"
               Text="{Binding Description, Mode=TwoWay}"
               SetupDocument="TxtDataProvider_SetupDocument" />
And the same code from my previous post in the handler for the SetupDocument event:
private void TxtDataProvider_SetupDocument(object sender, Telerik.Windows.Documents.FormatProviders.SetupDocumentEventArgs e)
        {
            e.Document.LineSpacing = 1;
        }

Regards,
Iva
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Jonathon
Top achievements
Rank 1
answered on 08 Sep 2011, 07:20 PM
Thanks, that's exactly what I needed.

Jonathon
Tags
RichTextBox
Asked by
tj
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Jonathon
Top achievements
Rank 1
Share this question
or