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

Page margin off when binding RichtextBox

3 Answers 164 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Kirk Quinbar
Top achievements
Rank 1
Kirk Quinbar asked on 20 Aug 2010, 10:30 PM
I am binding a RadRichTextbox though your HTMLDataProvider to a viewmodel. If you look at the attached image you will see the control is displaying a large margin around the text. the only way i could figure out how to change that margin is via the SetupDocument event on HtmlDataProvider as shown below in the codehind. I would prefer to not have any codebehind, so is there a way to change that margin on the xaml side. it seems as though every time it binds a change, the page margin goes back to some default. if that is true it seems like i should be able to change the default margin but i havent been able to figure it out. is it possible?



 

 

 

XAML:
<
documents:RadRichTextBox x:Name="EulaRichTextBox" Grid.Row="1" Grid.ColumnSpan="2" IsReadOnly="True" >

 

 

 

 

<documents:RadRichTextBox.Resources>

 

 

 

 

<documentsHtml:HtmlDataProvider x:Key="htmlDataProvider" RichTextBox="{Binding ElementName=EulaRichTextBox}" Html="{Binding EndUserAgreementVerbiage, Mode=TwoWay}" SetupDocument="HtmlDataProvider_SetupDocument" />

 

 

 

 

</documents:RadRichTextBox.Resources>

 

 

 

 

</documents:RadRichTextBox>

 


CodeBehind:

 

 

private void HtmlDataProvider_SetupDocument(object sender, Telerik.Windows.Documents.FormatProviders.SetupDocumentEventArgs e)

 

{

e.Document.SectionDefaultPageMargin =

 

new Telerik.Windows.Documents.Layout.Padding(10, 10, 10, 10);

 

}


3 Answers, 1 is accepted

Sort by
0
Ivailo Karamanolev
Telerik team
answered on 23 Aug 2010, 08:15 AM
Hello Kirk Quinbar,

Currently, the only way to customize the documents produced by the data providers is through the SetupDocument event. However, as some formats (like Xaml and Docx) internally save the page margins, overwriting that through the data providers would cause incorrect behavior. Therefore, I'd recommend to stick with the code that you currently have.
Let us know if we can assist you further.

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
0
Kirk Quinbar
Top achievements
Rank 1
answered on 23 Aug 2010, 02:57 PM
one suggestion i would have would be to add attributes we could setup on the xaml side as default margin settings (and other settings for that matter) that could be used anytime text or html is imported. in those situations we dont want the huge margin as it doesnt have to look like a word doc or whatever. and we also would prefer to not have code in our codebehind.yes your current SetupDocument event works, but forces us to have code in the codebehind. we normally dont as we are all about MVVM pattern and try to avoid it.

just a thought..

0
Ivailo Karamanolev
Telerik team
answered on 23 Aug 2010, 03:05 PM
Hi Kirk Quinbar,

Thank you for your suggestion. We have added this in our internal consideration list for further reviewing. Let us know if we can assist you further.

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
Tags
RichTextBox
Asked by
Kirk Quinbar
Top achievements
Rank 1
Answers by
Ivailo Karamanolev
Telerik team
Kirk Quinbar
Top achievements
Rank 1
Share this question
or